2

This is my current code used for the uploading task:

$imagesDropzone.dropzone init: -> this.on 'sending', (file, xhr) -> xhr.setRequestHeader 'Content-Type', file.type url: 'https://www.googleapis.com/upload/drive/v2/files?uploadType=media' method: 'post' maxFileSize: 5 paramName: 'images-dropzone-input' headers: 'Authorization': "Bearer #{ uploadBundle.accessToken }" addRemoveLinks: 'dictRemoveFile' 

And it doesn't work (all uploaded files are broken). I know I need to do something like this:

xhr.send file 

But I don't know where to put this call. How can I override the send behavior of Dropzone?

1 Answer 1

1

After take a look on the source code of Dropzone, I figure out a way to do it by overriding the instance method uploadFiles:

imagesDropzoneInstance = new Dropzone '#imagesDropzone', url: 'https://www.googleapis.com/upload/drive/v2/files?uploadType=media' method: 'post' maxFileSize: 5 paramName: 'images-dropzone-input' headers: 'Authorization': "Bearer #{ uploadBundle.accessToken }" addRemoveLinks: 'dictRemoveFile' imagesDropzoneInstance.uploadFiles = (files) -> uploadFiles: (files) -> .. copy the uploadFiles method of Dropzone, modify, then paste here.. # Add the end: xhr.send files[0] # This overrides the default upload behavior. 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.