这是我目前用于上传任务的代码:
app
|
src1->com->example->testing->Main.java
src2->com->another_example->another_testing->Library.java
它不起作用(所有上传的文件都被破坏)。 我知道我需要做这样的事情:
$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'
但我不知道该拨打电话的地点。如何覆盖Dropzone的xhr.send file
行为?
答案 0 :(得分:0)
在看了Dropzone的源代码之后,我想办法通过覆盖实例方法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.