Skip to content
Snippets Groups Projects
Commit 6fef90e1 authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub
Browse files

Merge pull request #5631 from RocketChat/fix-s3-upload-error

Fix error preventing showing error on upload to s3
parents b60af368 17fb9395
No related branches found
No related tags found
No related merge requests found
......@@ -10,20 +10,29 @@ FileUpload.AmazonS3 = class FileUploadAmazonS3 extends FileUploadBase {
this.uploader.send(this.file, (error, downloadUrl) => {
var file, item, uploading;
this.computation.stop();
if (this.computation) {
this.computation.stop();
}
if (error) {
uploading = Session.get('uploading');
if (uploading !== null) {
item = _.findWhere(uploading, {
id: this.id
if (!Array.isArray(uploading)) {
uploading = [];
}
item = _.findWhere(uploading, {
id: this.id
});
if (_.isObject(item)) {
item.error = error.error;
item.percentage = 0;
} else {
uploading.push({
error: error.error,
percentage: 0
});
if (item !== null) {
item.error = error.error;
item.percentage = 0;
}
Session.set('uploading', uploading);
}
Session.set('uploading', uploading);
} else {
file = _.pick(this.meta, 'type', 'size', 'name', 'identify', 'description');
file._id = downloadUrl.substr(downloadUrl.lastIndexOf('/') + 1);
......
......@@ -99,20 +99,21 @@ readAsArrayBuffer = (file, callback) ->
upload = fileUploadHandler record, file.file
upload.onProgress = (progress) ->
uploading = Session.get('uploading') or []
item = _.findWhere(uploading, {id: upload.id})
uploading = Session.get('uploading') or []
uploading.push
id: upload.id
name: upload.getFileName()
percentage: 0
if not item?
item =
id: upload.id
name: upload.getFileName()
Session.set 'uploading', uploading
uploading.push item
upload.onProgress = (progress) ->
uploading = Session.get('uploading')
item.percentage = Math.round(progress * 100) or 0
Session.set 'uploading', uploading
item = _.findWhere(uploading, {id: upload.id})
if item?
item.percentage = Math.round(progress * 100) or 0
Session.set 'uploading', uploading
upload.start()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment