From 8aeb044509ea247ce3dce99dfe1ff9b2501a56d0 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Mon, 24 Oct 2016 16:33:16 -0400 Subject: [PATCH] fix bug where plaintext files were being posted to s3 --- client/modules/IDE/actions/uploader.js | 4 ++-- client/modules/IDE/components/FileUploader.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/modules/IDE/actions/uploader.js b/client/modules/IDE/actions/uploader.js index 23e10b9e..c177ae51 100644 --- a/client/modules/IDE/actions/uploader.js +++ b/client/modules/IDE/actions/uploader.js @@ -1,6 +1,6 @@ import axios from 'axios'; import { createFile } from './files'; -const textFileRegex = /text\//; +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'; @@ -38,7 +38,7 @@ export function dropzoneAcceptCallback(file, done) { if (file.type.match(textFileRegex)) { localIntercept(file).then(result => { file.content = result; // eslint-disable-line - done(); + done('Uploading plaintext file locally.'); }) .catch(result => { done(`Failed to download file ${file.name}: ${result}`); diff --git a/client/modules/IDE/components/FileUploader.js b/client/modules/IDE/components/FileUploader.js index 52efaa02..2fc5618b 100644 --- a/client/modules/IDE/components/FileUploader.js +++ b/client/modules/IDE/components/FileUploader.js @@ -24,7 +24,7 @@ class FileUploader extends React.Component { thumbnailWidth: 200, thumbnailHeight: 200, // TODO what is a good list of MIME types???? - acceptedFiles: 'image/*,audio/*,text/javascript,text/html,text/css,application/json,application/x-font-ttf,application/x-font-truetype', + acceptedFiles: 'image/*,audio/*,text/javascript,text/html,text/css,application/json,application/x-font-ttf,application/x-font-truetype,text/plain', dictDefaultMessage: 'Drop files here to upload or click to use the file browser', accept: this.props.dropzoneAcceptCallback, sending: this.props.dropzoneSendingCallback,