diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js index 9d66f2e4..a19a2cef 100644 --- a/js/components/ascribe_uploader/react_s3_fine_uploader.js +++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js @@ -229,7 +229,6 @@ var ReactS3FineUploader = React.createClass({ onDeleteComplete: this.onDeleteComplete, onSessionRequestComplete: this.onSessionRequestComplete, onError: this.onError, - onValidate: this.onValidate, onUploadChunk: this.onUploadChunk, onUploadChunkSuccess: this.onUploadChunkSuccess } @@ -425,13 +424,17 @@ var ReactS3FineUploader = React.createClass({ GlobalNotificationActions.appendGlobalNotification(notification); }, - onValidate(data) { - if(data.size > this.props.validation.sizeLimit) { - this.state.uploader.cancelAll(); + isFileValid(file) { + if(file.size > this.props.validation.sizeLimit) { let fileSizeInMegaBytes = this.props.validation.sizeLimit / 1000000; - let notification = new GlobalNotificationModel(getLangText('Your file is bigger than ' + fileSizeInMegaBytes + 'MB.'), 'danger', 5000); + + let notification = new GlobalNotificationModel(getLangText('A file you submitted is bigger than ' + fileSizeInMegaBytes + 'MB.'), 'danger', 5000); GlobalNotificationActions.appendGlobalNotification(notification); + + return false; + } else { + return true; } }, @@ -581,8 +584,18 @@ var ReactS3FineUploader = React.createClass({ return; } + // validate each submitted file if it fits the file size + let validFiles = []; + for(let i = 0; i < files.length; i++) { + if(this.isFileValid(files[i])) { + validFiles.push(files[i]); + } + } + // override standard files list with only valid files + files = validFiles; + // Call this method to signal the outside component that an upload is in progress - if(this.props.uploadStarted && typeof this.props.uploadStarted === 'function') { + if(this.props.uploadStarted && typeof this.props.uploadStarted === 'function' && files.length > 0) { this.props.uploadStarted(); }