Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transfer images through REST API

I have a mobile application which needs to display images which will be sent to it via REST API. How do I tranfser images ove the API? I am developing a ASP.net Web API using C#.

I tried converting image to base64 then send it though API to the mobile device, but this seems to take a lot of time as I have to send large number of images to my mobile device in one run.

I need to send image file along with some other data through the API to mobile device and a Phonegap android will then save it in local db for further use. Any help would be appreciated.

like image 404
Arti Avatar asked Oct 18 '22 22:10

Arti


1 Answers

If you want to sent the images alongside other data in one request using base64 is the best way.

You could think of using gzip to compress the image data to reduce the size. An other way would be to send the images in a reduced size to your android client alonside with a URL to a fully sized image. This enables you to show you results quickly to the user and then load the large images in a background task from the server and replace the small ones in the database.

like image 84
crysxd Avatar answered Nov 15 '22 04:11

crysxd