cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the file size before upload sap.ca.ui.FileUpload

Former Member
0 Kudos

Hi All,

I am using sap.ca.ui.FileUpload . There is a getSize function which return the file size from the model . Is there a way to find it before upload so that upload could be stopped for above a set Threshold ? Currently as soon as plus button is pressed , upload starts .

Kindly suggest.

Regards

Mayank Jain

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Use beforeUploadFile event  which triggers before fileupload.


https://sapui5.netweaver.ondemand.com/sdk/docs/api/symbols/sap.ca.ui.FileUpload.html#event:beforeUpl...

Sample code to get the file that user tries to upload.

onBeforeUploadFile: function (e)

{

uFile = this.byId("fileupload").getModel().getData().dataitems[0];      

}

uFile.size will have the size of the file.

Hope this will be useful!

Regards,

Meganadhan S

Former Member
0 Kudos

Hi,

I had actually tried this but due to some strange reason the size property is not there in the object : Object {documentId: "0.34490414266474545", filename: "JSON.txt", "": "915 Bytes", isPending: false, isUploading: true…}.

The library version is 1.22.3

Regards

Mayank Jain