Allow functions or strings for URL options. #742
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow users to provide either a string or a function for the
method
and
url
options. If a function is provided, call withfiles
inuploadFiles
; else pass the string value. This can be useful whendifferent 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
andDropzone.options.method
.