cancel
Showing results for 
Search instead for 
Did you mean: 

FileUploader, how to add Parameters?

Former Member
0 Kudos

Hi experts,

I'm trying to import an excel file into a table using the FileUploader control.

For that i need to send the table content to the backend together with the file.

I saw there is a property parameters[] in this control, but i don't really get it how to use it.

In the "change" event from the control, I'm trying to add some parameters, but it doesn't accept them with fileUploader.addParameter("someContent")

What kind of values does this method accept?

and what is the best way to send some data to the backend through the fileUploader control?

Regards,

Georgi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The problem was that we are using an older version of the sapUi5 library.

The sap.ui.unified.FileUploaderParameter is since version 1.21.0. and with versions below we need to use the sap.ui.commons.FileUploaderParameter

Thanks for the help!

Answers (2)

Answers (2)

kai2015
Contributor
0 Kudos

If you use the search function here, you will find a blog called "Upload Image to SAP Gateway and ...".

There you can read about how to upload a file.

kai2015
Contributor
0 Kudos

I don't have used the fileuploader yet.

But have you already read the API about that control?

SAPUI5 API

addParameter

Parameters:

{sap.ui.unified.FileUploaderParameter} oParameter

- the parameter to add; if empty, nothing is inserted

So you have to give him a sap.ui.unified.FileUploaderParameter ...

Former Member
0 Kudos

Yes i already read that, but when i try to add it like this:

uploader.addParameter(new sap.ui.unified.FileUploaderParameter(exportObject));

it thorws an error that : Uncaught Error: "[object Object]" is not valid for aggregation "parameters" of Element sap.ui.commons.FileUploader

I'll check that blog,

thanks!

kai2015
Contributor
0 Kudos

and what kind of object is your "exportObject" ?

Because the FileUploaderParameter has two Parameters:

Parameters:

{string}sId?id for the new control, generated automatically if no id is given
{object}mSettings?initial settings for the new control
Former Member
0 Kudos

It is an Object with JSON data inside

kai2015
Contributor
0 Kudos

The valid JSON for that looks like:

{name: "value1", value: "MyFile"} or how is yours structed?

Former Member
0 Kudos

exactly the same:

uploader.addParameter(test), where test{name : "value", value: "value1"}

kai2015
Contributor
0 Kudos

So then there is another mistake. Because its working. Look here:

JS Bin No console errors ---

please share your example code at JS Bin.