Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ React.render(<Upload />, container);
|supportServerRender | boolean | false| whether to support server render |
|onReady | function | | only call when supportServerRender is true, upload is rendered completely |
|action| string &#124; function(file): string &#124; Promise&lt;string&gt; | | form action url |
|method | string | post | request method |
|directory| boolean | false | support upload whole directory |
|data| object/function(file) | | other data object to post or a function which returns a data object |
|headers| object | {} | http headers to post, available in modern browsers |
Expand Down
1 change: 1 addition & 0 deletions src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class AjaxUploader extends Component {
file: transformedFile,
headers: props.headers,
withCredentials: props.withCredentials,
method: props.method || 'post',
onProgress: onProgress ? e => {
onProgress(e, file);
} : null,
Expand Down
6 changes: 3 additions & 3 deletions src/request.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function getError(option, xhr) {
const msg = `cannot post ${option.action} ${xhr.status}'`;
const msg = `cannot ${option.method} ${option.action} ${xhr.status}'`;
const err = new Error(msg);
err.status = xhr.status;
err.method = 'post';
err.method = option.method;
err.url = option.action;
return err;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function upload(option) {
};


xhr.open('post', option.action, true);
xhr.open(option.method, option.action, true);

// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
if (option.withCredentials && 'withCredentials' in xhr) {
Expand Down
1 change: 1 addition & 0 deletions tests/request.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const option = {
filename: 'a.png',
file: 'foo',
headers: { from: 'hello' },
method: 'post',
};

describe('request', () => {
Expand Down