Passing different parameter value for each upload queue #883

Open
opened 2017-09-03 06:19:53 +00:00 by hftey · 8 comments
hftey commented 2017-09-03 06:19:53 +00:00 (Migrated from github.com)

ng2-file-upload-paramter
I need to pass additional information for each file upload. Looking at the snapshot, user can change the document types before the file is being uploaded. How do I tie each options selected by the user to the upload itself. I had tried with onBuildItemForm but I am not sure how to tie the option selected for that particular item and append that to the individual queue form. Any help or guide is much appreciated

![ng2-file-upload-paramter](https://user-images.githubusercontent.com/4142162/30000994-126de9b8-90c3-11e7-9171-dc5b4450fa26.png) I need to pass additional information for each file upload. Looking at the snapshot, user can change the document types before the file is being uploaded. How do I tie each options selected by the user to the upload itself. I had tried with onBuildItemForm but I am not sure how to tie the option selected for that particular item and append that to the individual queue form. Any help or guide is much appreciated
ppprevost commented 2017-09-11 12:57:47 +00:00 (Migrated from github.com)

same

same
stephenad commented 2017-10-04 16:08:58 +00:00 (Migrated from github.com)

Any one get any solutions on this?

Any one get any solutions on this?
rahul-krish commented 2017-12-15 06:28:44 +00:00 (Migrated from github.com)

+1
I want to send a parameter so that I can check which folder to upload that specific file. I have different folders for different types of files

+1 I want to send a parameter so that I can check which folder to upload that specific file. I have different folders for different types of files
webchetan commented 2018-05-04 16:38:29 +00:00 (Migrated from github.com)

I am looking for the same answer. Unfortunately no one knows a solution to this. I was able to achieve it for a single file upload at a time but doesn't work when multiple files are getting uploaded.

I am looking for the same answer. Unfortunately no one knows a solution to this. I was able to achieve it for a single file upload at a time but doesn't work when multiple files are getting uploaded.
sunil233 commented 2018-05-06 02:37:37 +00:00 (Migrated from github.com)

how to pass the formdata or additional parameters(documenttype,document description..) to the REST webApi?
My Api is
public IHttpActionResult Upload()
{
}

how to pass the formdata or additional parameters(documenttype,document description..) to the REST webApi? My Api is public IHttpActionResult Upload() { }
d4rkc0de commented 2018-05-12 01:52:23 +00:00 (Migrated from github.com)

any updates guys?

any updates guys?
koenvanderlinden commented 2018-05-14 11:47:00 +00:00 (Migrated from github.com)

Maybe you can use formatDataFunction from simple-demo.ts.

So by just inspecting the sources.
Set options.disableMultipart = true.
Set options.formatDataFunctionIsAsync = false;

Create a delegate method on options.formatDataFunction(item). I this case should return a FormData object.

Your formatDataFunction function does something like:

	  let myForm = new FormData();
	  // add files
      myForm.append(item.alias, item._file, item.file.name);
     
	 // add addition parameters to formData
      myForm.append(someKey, someParamValue); // add your logic here. You should retreive you values from your own model.

The uploader file-uploader.class.ts does a xhr.send(sendable) when option.formatDataFunctionIsAsync = false.
xhr is a XMLHttpRequest and send the formdata.
sendable is the object you created using the formatDataFunction.

Hope this helps.

Maybe you can use formatDataFunction from [simple-demo.ts](https://github.com/valor-software/ng2-file-upload/blob/development/demo/src/app/components/file-upload/simple-demo.ts). So by just inspecting the sources. Set options.disableMultipart = true. Set options.formatDataFunctionIsAsync = false; Create a delegate method on options.formatDataFunction(item). I this case should return a FormData object. Your formatDataFunction function does something like: ``` let myForm = new FormData(); // add files myForm.append(item.alias, item._file, item.file.name); // add addition parameters to formData myForm.append(someKey, someParamValue); // add your logic here. You should retreive you values from your own model. ``` The uploader [file-uploader.class.ts](https://github.com/valor-software/ng2-file-upload/blob/development/src/file-upload/file-uploader.class.ts) does a xhr.send(sendable) when option.formatDataFunctionIsAsync = false. xhr is a [XMLHttpRequest](https://developer.mozilla.org/nl/docs/Web/API/XMLHttpRequest) and send the formdata. sendable is the object you created using the formatDataFunction. Hope this helps.
jayeshanandani commented 2019-05-10 11:01:03 +00:00 (Migrated from github.com)

any update on this?

any update on this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#883