-
-
Save FerraBraiZ/d623f95fea7c44961df5456e5f0dbaa3 to your computer and use it in GitHub Desktop.
DropZone stub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
Dropzone.autoDiscover = false; | |
const fileTypesWhiteList = "jpeg|jpg|gif|png|bmp|pdf|doc|docx|txt|odt"; | |
let dropZoneFileUploader = new Dropzone("#dz-custom-file-upload-form",{ | |
autoDiscover: false, | |
autoProcessQueue:false, | |
uploadMultiple: true, | |
addRemoveLinks: true, | |
forceFallback: false, | |
url: "localhost:8080/file-upload", | |
parallelUploads: 15, | |
maxFilesize: 25, // MB | |
acceptedFiles: ".jpeg,.jpg,.gif,.png,.bmp,.pdf,.doc,.docx,.txt,.odt", | |
dictResponseError: "Erro: upload falhou!", | |
dictInvalidFileType: "Tipo de arquivo não suportado", | |
dictFileTooBig: "Tamanho máximo ( 25Mb ) excedido!", | |
dictRemoveFile: "Excluir arquivo", | |
dictCancelUpload: "Cancelar upload", | |
dictCancelUploadConfirmation: "Tem certeza que deseja cancelar?", | |
previewsContainer: "#custom-dz-previews-container", | |
withCredentials: false, | |
headers: { | |
"Access-Control-Max-Age": null, | |
"Access-Control-Allow-Headers": null, | |
"Access-Control-Allow-Credentials": null, | |
"Authorization": null, | |
"X-Requested-With": null, | |
"Accept": null, | |
"Content-Type": null, | |
"Origin": null, | |
"Cache-Control": null, | |
"X-File-Name": null, | |
}, | |
init: function(){ | |
// Add some data with the form to be sent alongside with files... | |
this.on( "sending", function (file, xhr, formData) { | |
formData.append("token", 'ce071bbb-5137-48b7-9790-841e53ab036a' ); | |
}); | |
this.on( "addedfile", function( file ){ | |
//remove files that are not supported automatically | |
if( false === new RegExp( fileTypesWhiteList ).test( file.type.split("/")[1] ) ) | |
{ | |
this.removeFile( file ); | |
} | |
}); | |
this.on( 'error', function( $error ){ | |
//your callback function | |
console.error( $error ); | |
}); | |
this.on( "success", function( $file ){ | |
//your callback function | |
console.log({...$file}); | |
}); | |
this.on( "removedfile", function( $file ){ | |
//your callback function | |
console.log({...$file}); | |
}); | |
this.on( "reset", function(){ | |
//your callback function | |
}); | |
this.on( "queuecomplete", function(){ | |
//your callback function | |
}); | |
} | |
}); | |
}catch(e){ | |
console.error('DROPZONE ERROR'); | |
console.trace( e ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment