cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload image using odata services in sapui5

Former Member
0 Kudos

I want to upload image using js view and controller with odata services

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member340030
Contributor
0 Kudos

Hi Kallesh ,

It depends on your backend upload service, what kind of data we need to POST.

On UI5 side you just check out this example : https://sapui5.netweaver.ondemand.com/sdk/explored.html#/sample/sap.m.sample.UploadCollection/previe...

Just understand the different events of uploader like onChange you need to set headers of your post and on upload complete you need to refresh the model with new uploaded content

thanks

Viplove

Former Member
0 Kudos

Thank you sir...

Former Member
0 Kudos

Viplove Sir,

I tried lot but i am unable to solve image upload using odata service in sapui5. I am new to sapui5. If you have code related to image upload using odata services in sapui5 please send me.

Thanks

Kallesh KS

former_member340030
Contributor
0 Kudos

Hi Kallesh ,

If your backend service to upload the image is a form upload than you just need to call like below :

var oFileUploader = sap.ui.getCore().byId("<id of the file uploader>"); // or this,getView().byId(" <id of the file uploader>" )

oFileUploader.upload();

// this will automatically uploads you selected file in the file uploader control. in the file uploader you need to specify the upload url

And if you background service accepts bytes array string .. than you need to convert your image into byte array and than send them in the POST request.

thanks

Viplove