It seems that the old
setParams function caused a lot of confusion among developers utilizing Fine Uploader in their projects. Historically, the
setParams function could only be called in your
onSubmit callback. Any calls after this point would result in changes to the parameters for the next file sent, and not the current file. Furthermore, calling the
setParams function would result in replacement of the params passed along with ALL files after that point. If you only wanted to change the parameters for one file, you would have to call
setParams again the NEXT time you handle an
onSubmit callback, passing in the original parameters.
3.1 brings along some much needed improvements to the
setParams function. Also, my changes will NOT break any existing code. If you, for some reason, like the way
setParams has functioned up until now, or you simply don’t want to adjust your code to take advantage of the improvements, you can leave your code alone any everything should work as it did before.
Change parameters at ANY point
Now, you can utilize
setParams to change parameters passed at any point in the upload process. For the current file, you can adjust the parameters passed along with the request as late as the
onUpload callback. You can also adjust parameters for a file in
onManualRetry and onAutoRetry callbacks.
Easily change parameters only for a specific file
setParams function has been improved to take an optional file ID parameter. So, if you only want to change the parameters passed for a specific file, simply pass your parameters object, along with the file ID to the
setParams function. This may be especially useful for users that have the
autoUpload parameter set to
false. If you want to change parameters for all files, you can still do that by omitting the file ID parameter.
The new signature is
setParams(Object params, [optional] Integer fileId).
- Once you change parameters for a specific file by specifying its ID in your
setParamscall, calls to
setParamswithout a file ID will NOT affect this file. If you want to adjust parameters AGAIN for such a file, you will need to call
setParamsagain, specifying that file’s ID.
- In 3.1, the file ID’s for all internal uploaders are now consistent. Previously, the form uploader would use a string ID, such as “qq-uploader-handler-iframe” followed by a number. The XHR uploader would simply use a number for IDs. Now, both internal uploaders simply use a number, so you can expect that the IDs for all files will always be integers.
As always, please let me know if you would like any further improvements, or if you have any concerns or questions.