Add Additional Parameter to FileItem on Init #842

Closed
opened 2017-07-11 10:56:46 +00:00 by Rocinante89 · 0 comments
Rocinante89 commented 2017-07-11 10:56:46 +00:00 (Migrated from github.com)

I'm having a bit of an issue with adding additional parameters. My use case is that I need to be able to add multiple documents on file drop, and then using checkboxes set some of them as contracts. I know I can use uploader = new FileUploader({ url: URL, method: 'post', additionalParameter: { isContract: false } }); to add a new parameter, but this is at the uploader level, and checking one checkbox will set all FileItems as true.
I also know that there is this.uploader.onBuildItemForm = (fileItem, form) => { form.append('isContract', 'true'); return { fileItem, form } }; too, but I can't think of a clean way to alter this on click of a checkbox without making an array of bools of the same size as my uploader.queue... which seems a bit hacky.

Is ther any clean way of achieving what I need to do?

I'm having a bit of an issue with adding additional parameters. My use case is that I need to be able to add multiple documents on file drop, and then using checkboxes set some of them as contracts. I know I can use `uploader = new FileUploader({ url: URL, method: 'post', additionalParameter: { isContract: false } });` to add a new parameter, but this is at the uploader level, and checking one checkbox will set all FileItems as true. I also know that there is `this.uploader.onBuildItemForm = (fileItem, form) => { form.append('isContract', 'true'); return { fileItem, form } };` too, but I can't think of a clean way to alter this on click of a checkbox without making an array of bools of the same size as my uploader.queue... which seems a bit hacky. Is ther any clean way of achieving what I need to do?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#842