cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to add parameters to UploadSet?

MioYasutake
SAP Champion
SAP Champion
0 Likes
3,750

Hi community,

I'm trying to upload files to Document Management Service.

To do so, I need to send some form data together with a file. The screenshot below is the actual form data sent.

With UploadCollection we would do this by the following code.

        onAttachmentsChange: function (oEvent) {
            var oUploadCollection = oEvent.getSource();
            oUploadCollection.addParameter(new UploadCollectionParameter({
                name: "cmisAction",
                value: "createDocument" // create file
            }));

            oUploadCollection.addParameter(new UploadCollectionParameter({
                name: "propertyId[0]",
                value: "cmis:objectTypeId"
            }));

            oUploadCollection.addParameter(new UploadCollectionParameter({
                name: "propertyValue[0]",
                value: "cmis:document"
            }));

            oUploadCollection.addParameter(new UploadCollectionParameter({
                name: "propertyId[1]",
                value: "cmis:name"
            }));

            oUploadCollection.addParameter(new UploadCollectionParameter({
                name: "propertyValue[1]",
                value: oEvent.getParameter("files")[0].name
            }));
        },

Now that UploadCollection is deprecated, I want to implement upload using UploadSet.

However, in UploadSet I cannot find a method equivalent to addParameter() in UploadCollection.

How can I add parameters to UploadSet? Or, should I fall back to UploadCollection for this case?

Best regards,

Mio

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Likes

Hello @MioYasutake ,

I am facing the same issue as you, but I think you have the solution so far, but I would like to update my research to help anyone have the same problem :D.

I have solved my issue with the solution below; that's an awesome solution. Hope it will be useful.


https://github.com/SAP/openui5/issues/3381

Best regards,
Huy Nguyen

Yogananda
Product and Topic Expert
Product and Topic Expert
0 Likes

mioyasutake

You can add parameters to an UploadSet using the setParameters() method.

// create a new UploadSet object
let uploadSet = new UploadSet();

// define the parameters
let params = {
    maxFileSize: "2MB",
    allowedMimeTypes: ["image/jpeg", "image/png"],
    maxNumberOfFiles: 10
};

// add the parameters to the UploadSet
uploadSet.setParameters(params);
MioYasutake
SAP Champion
SAP Champion
0 Likes

Hi yoganandamuthaiah,

Thanks for your reply.

I couldn't find setParameters() in the document, but is this available?