Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow functions or strings for URL options. #742

Merged
merged 1 commit into from
Nov 29, 2014
Merged

Conversation

jmcarp
Copy link
Contributor

@jmcarp jmcarp commented Nov 2, 2014

Allow users to provide either a string or a function for the method
and url options. If a function is provided, call with files in
uploadFiles; else pass the string value. This can be useful when
different files need to be sent with different methods or URLs.

This patch came out of the development of hgrid.js, a hierarchical data browser that uses Dropzone for uploads to different directories. HGrid stores upload destination information on the file objects, so we had to monkey-patch Dropzone to allow it to use a function to build upload URLs and methods on a per-file basis. This patch would give users of Dropzone more control over how upload URLs and methods are built, but without complicating the API for developers who don't need that flexibility, since either a string or a function can be provided for Dropzone.options.url and Dropzone.options.method.

Allow users to provide either a string or a function for the `method`
and `url` options. If a function is provided, call with `files` in
`uploadFiles`; else pass the string value. This can be useful when
different files need to be sent with different methods or URLs.
enyo added a commit that referenced this pull request Nov 29, 2014
Allow functions or strings for URL options.
@enyo enyo merged commit 2d1238b into dropzone:master Nov 29, 2014
@enyo
Copy link
Collaborator

enyo commented Nov 29, 2014

Thank you

@javadoug
Copy link

This feature is incomplete. There is a bug on line. If you set method to a function this line gives a javascript error bc a function does not have the String function toUpperCase.

FYI: the workaround is to update options.method in the 'processing' event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants