Skip to content

Commit

Permalink
Merge pull request #537 from VeliovGroup/dev
Browse files Browse the repository at this point in the history
v1.9.4
  • Loading branch information
dr-dimitru authored Dec 13, 2017
2 parents 76a3c82 + 3d99cc2 commit 376e46e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ [email protected]
[email protected]
[email protected]
ostrio:[email protected]
ostrio:[email protected].3
ostrio:[email protected].4
[email protected]
[email protected]
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'ostrio:files',
version: '1.9.3',
version: '1.9.4',
summary: 'File upload via DDP/HTTP to server, 3rd party storage support: AWS S3, GridFS, DropBox and others',
git: 'https://github.com/VeliovGroup/Meteor-Files',
documentation: 'README.md'
Expand Down
24 changes: 21 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,25 @@ export class FilesCollection extends FilesCollectionCore {
WebApp.connectHandlers.use((httpReq, httpResp, next) => {
if (!this.disableUpload && !!~httpReq._parsedUrl.path.indexOf(`${this.downloadRoute}/${this.collectionName}/__upload`)) {
if (httpReq.method === 'POST') {
const handleError = (error) => {
const handleError = (_error) => {
let error = _error;
console.warn('[FilesCollection] [Upload] [HTTP] Exception:', error);
console.trace();

if (!httpResp.headersSent) {
httpResp.writeHead(500);
}

if (!httpResp.finished) {
httpResp.end(JSON.stringify({error}));
if (_.isObject(error) && _.isFunction(error.toString)) {
error = error.toString();
}

if (!_.isString(error)) {
error = 'Unexpected error!';
}

httpResp.end(JSON.stringify({ error }));
}
};

Expand Down Expand Up @@ -508,8 +520,12 @@ export class FilesCollection extends FilesCollectionCore {
opts = {file: {}};
}

if (!_.isObject(opts.file)) {
opts.file = {};
}

opts.___s = true;
this._debug(`[FilesCollection] [File Start HTTP] ${opts.file.name} - ${opts.fileId}`);
this._debug(`[FilesCollection] [File Start HTTP] ${opts.file.name || '[no-name]'} - ${opts.fileId}`);
if (_.isObject(opts.file) && opts.file.meta) {
opts.file.meta = fixJSONParse(opts.file.meta);
}
Expand All @@ -530,6 +546,7 @@ export class FilesCollection extends FilesCollectionCore {
if (!httpResp.headersSent) {
httpResp.writeHead(200);
}

if (!httpResp.finished) {
httpResp.end(JSON.stringify({
uploadRoute: `${this.downloadRoute}/${this.collectionName}/__upload`,
Expand All @@ -540,6 +557,7 @@ export class FilesCollection extends FilesCollectionCore {
if (!httpResp.headersSent) {
httpResp.writeHead(204);
}

if (!httpResp.finished) {
httpResp.end();
}
Expand Down

0 comments on commit 376e46e

Please sign in to comment.