diff --git a/client/modules/IDE/actions/uploader.js b/client/modules/IDE/actions/uploader.js index fa8229e8..fb7976dc 100644 --- a/client/modules/IDE/actions/uploader.js +++ b/client/modules/IDE/actions/uploader.js @@ -4,6 +4,7 @@ const textFileRegex = /(text\/|application\/json)/; const s3BucketHttps = `https://s3-us-west-2.amazonaws.com/${process.env.S3_BUCKET}/`; const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; +const MAX_LOCAL_FILE_SIZE = 80000; // bytes, aka 80 KB function localIntercept(file, options = {}) { return new Promise((resolve, reject) => { @@ -34,7 +35,7 @@ export function dropzoneAcceptCallback(file, done) { // for text files and small files // check mime type // if text, local interceptor - if (file.type.match(textFileRegex)) { + if (file.type.match(textFileRegex) && file.size < MAX_LOCAL_FILE_SIZE) { localIntercept(file).then(result => { file.content = result; // eslint-disable-line done('Uploading plaintext file locally.'); @@ -74,7 +75,7 @@ export function dropzoneAcceptCallback(file, done) { export function dropzoneSendingCallback(file, xhr, formData) { return () => { - if (!file.type.match(textFileRegex)) { + if (!file.type.match(textFileRegex) || file.size >= MAX_LOCAL_FILE_SIZE) { Object.keys(file.postData).forEach(key => { formData.append(key, file.postData[key]); }); @@ -87,7 +88,7 @@ export function dropzoneSendingCallback(file, xhr, formData) { export function dropzoneCompleteCallback(file) { return (dispatch, getState) => { // eslint-disable-line - if (!file.type.match(textFileRegex) && file.status !== 'error') { + if ((!file.type.match(textFileRegex) || file.size >= MAX_LOCAL_FILE_SIZE) && file.status !== 'error') { let inputHidden = '