show error messages for invalid files
This commit is contained in:
parent
7cba11f90c
commit
61925b67e4
2 changed files with 7 additions and 8 deletions
|
@ -34,7 +34,6 @@ export function dropzoneAcceptCallback(file, done) {
|
|||
// for text files and small files
|
||||
// check mime type
|
||||
// if text, local interceptor
|
||||
console.log(file.type);
|
||||
if (file.type.match(textFileRegex)) {
|
||||
localIntercept(file).then(result => {
|
||||
file.content = result; // eslint-disable-line
|
||||
|
@ -88,7 +87,7 @@ export function dropzoneSendingCallback(file, xhr, formData) {
|
|||
|
||||
export function dropzoneCompleteCallback(file) {
|
||||
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="';
|
||||
const json = {
|
||||
url: `${s3BucketHttps}${file.postData.key}`,
|
||||
|
@ -103,9 +102,8 @@ export function dropzoneCompleteCallback(file) {
|
|||
name: file.name,
|
||||
url: `${s3BucketHttps}${file.postData.key}`
|
||||
};
|
||||
console.log(formParams);
|
||||
createFile(formParams)(dispatch, getState);
|
||||
} else {
|
||||
} else if (file.content !== undefined) {
|
||||
const formParams = {
|
||||
name: file.name,
|
||||
content: file.content
|
||||
|
|
|
@ -23,6 +23,7 @@ class FileUploader extends React.Component {
|
|||
maxThumbnailFilesize: 8, // 3MB
|
||||
thumbnailWidth: 200,
|
||||
thumbnailHeight: 200,
|
||||
addRemoveLinks: true,
|
||||
// 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,
|
||||
|
@ -31,10 +32,10 @@ class FileUploader extends React.Component {
|
|||
accept: this.props.dropzoneAcceptCallback,
|
||||
sending: this.props.dropzoneSendingCallback,
|
||||
complete: this.props.dropzoneCompleteCallback,
|
||||
error: (file, errorMessage) => {
|
||||
console.log(file);
|
||||
console.log(errorMessage);
|
||||
}
|
||||
// error: (file, errorMessage) => {
|
||||
// console.log(file);
|
||||
// console.log(errorMessage);
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue