cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Additional Parameters (SLUG) to sap.m.uploadCollection

Former Member
0 Kudos

Dear All,

Kindly help to find out a way to add additional request parameters (SLUG) while uploading a file from UI5 front end through gateway using Sap.M.UploadCollection control before uploading the file.

insertCollectionParameter is working but i would like to add dynamic parameters before the POST request is fired.

Kindly help accordingly.

Thanks,

Rumeshbabu S

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

slug is one of the header parameters, if you want to add multiple values i suggest you use a separator, e.g. "|" so you can easily split the parameters in the backend.

e.g.

var oHeaders = {

                    "x-csrf-token" : header_xcsrf_token,

                    "slug" : sap.ui.getCore().byId('masterSelect')

                            .getSelectedKey()

                            + "|"

                            + file.name

                            + "|"

                            + file.type

                            + "|"

                            + sap.ui.getCore().byId('bestandsNaam').getValue()

                            + "|"

                            + sap.ui.getCore().byId('typeSelect')

                                    .getSelectedItem().getId(),

                };

if you want something dynamic, you could use a javascript array:

var slug = slugArray.join("|");

in backend:

CONSTANTS:

  gc_delimiter(1)    TYPE c  VALUE '|'.

SPLIT iv_slug AT gc_delimiter into itab_slug.

Kind regards,

RW

Former Member
0 Kudos

Thanks Robbe,

But I would like to add the header to uploadcollection control during at the time of selecting the file or before the POST is fired, Since this control immediately fire the POST once the file is selected.

Typically i am looking for an event which gets triggered before the file is uploaded, like sap.ca.ui.FileUpload.beforeUploadFile.

So that i can add my additional parameters on that event.

Regards,

Rumeshbabu S

Former Member
0 Kudos

not sure, but have you tested the attachChange function?

Former Member
0 Kudos

Many Thanks Robbie,

The event "change" is getting executed the once the file is selected from the open file dialog & all the details related to the selected files (FileName, FileType etc ) are coming as event parameters.

With sap.m.addHeaderParameter i think we can pass "slug" parameters as you suggested to get the additional parameters in the backend.

Regards,

Rumeshbabu S

Former Member
0 Kudos

you're welcome

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

do you need HTTP header parameters ?

UploadCollection._getFileUploader().addHeaderParameters( new sap.ui.unified.FileUploaderParameter(

{

name : "NAME",

value : "VALUE"

}

) );

Former Member
0 Kudos

Thanks Maksim,

I hope this will work, but even with this approach i think we couldn't able to add any additional parameters before the POST is fired & after the file is selected.

@Robbie,

Have to check that change event .

Thanks & Regards,

Rumeshbabu S

former_member182372
Active Contributor
0 Kudos

those parameters will be added with each request