show error messages for invalid files

This commit is contained in:
Cassie Tarakajian 2016-10-24 21:15:32 -04:00
parent 7cba11f90c
commit 61925b67e4
2 changed files with 7 additions and 8 deletions

View file

@ -34,7 +34,6 @@ export function dropzoneAcceptCallback(file, done) {
// for text files and small files // for text files and small files
// check mime type // check mime type
// if text, local interceptor // if text, local interceptor
console.log(file.type);
if (file.type.match(textFileRegex)) { if (file.type.match(textFileRegex)) {
localIntercept(file).then(result => { localIntercept(file).then(result => {
file.content = result; // eslint-disable-line file.content = result; // eslint-disable-line
@ -88,7 +87,7 @@ export function dropzoneSendingCallback(file, xhr, formData) {
export function dropzoneCompleteCallback(file) { export function dropzoneCompleteCallback(file) {
return (dispatch, getState) => { // eslint-disable-line return (dispatch, getState) => { // eslint-disable-line
if (!file.type.match(textFileRegex)) { if (!file.type.match(textFileRegex) && file.status !== 'error') {
let inputHidden = '<input type="hidden" name="attachments[]" value="'; let inputHidden = '<input type="hidden" name="attachments[]" value="';
const json = { const json = {
url: `${s3BucketHttps}${file.postData.key}`, url: `${s3BucketHttps}${file.postData.key}`,
@ -103,9 +102,8 @@ export function dropzoneCompleteCallback(file) {
name: file.name, name: file.name,
url: `${s3BucketHttps}${file.postData.key}` url: `${s3BucketHttps}${file.postData.key}`
}; };
console.log(formParams);
createFile(formParams)(dispatch, getState); createFile(formParams)(dispatch, getState);
} else { } else if (file.content !== undefined) {
const formParams = { const formParams = {
name: file.name, name: file.name,
content: file.content content: file.content

View file

@ -23,6 +23,7 @@ class FileUploader extends React.Component {
maxThumbnailFilesize: 8, // 3MB maxThumbnailFilesize: 8, // 3MB
thumbnailWidth: 200, thumbnailWidth: 200,
thumbnailHeight: 200, thumbnailHeight: 200,
addRemoveLinks: true,
// TODO what is a good list of MIME types???? // TODO what is a good list of MIME types????
acceptedFiles: `image/*,audio/*,text/javascript,text/html,text/css, acceptedFiles: `image/*,audio/*,text/javascript,text/html,text/css,
application/json,application/x-font-ttf,application/x-font-truetype, application/json,application/x-font-ttf,application/x-font-truetype,
@ -31,10 +32,10 @@ class FileUploader extends React.Component {
accept: this.props.dropzoneAcceptCallback, accept: this.props.dropzoneAcceptCallback,
sending: this.props.dropzoneSendingCallback, sending: this.props.dropzoneSendingCallback,
complete: this.props.dropzoneCompleteCallback, complete: this.props.dropzoneCompleteCallback,
error: (file, errorMessage) => { // error: (file, errorMessage) => {
console.log(file); // console.log(file);
console.log(errorMessage); // console.log(errorMessage);
} // }
}); });
} }