Receive image and save in database-django view - android

I'm working on an application where the client side is android and the server side is django. I usually send data to the server using post requests and recieve them at the server side in this way
e.g. name = request.POST['name']
I need now to receive the image in the server side and save it to the database. The image was converted at the client side(android) to base64 string so how can I convert that string to image at the server side and save it in the database?!
Any help?!

Have a look at a similar question, found here. If you do this, then you can just save the reference to the database for the image, or save the base64 string to the database.

Related

Recover an image from an android to send to server

I am currently working on an android application and I would like to add a file system to send images. But I don't know how to get an image from the local storage of an android, nor how to send it to a server. I am currently using a flask server to retrieve JSON files, and I don't know if retrieving images would be possible with this kind of server.
Would you have any clue how to retrieve a file on a button press and send it to a server please?
You can use this library to pick from local storage and upload it to the server with ease
https://github.com/gotev/android-upload-service
At this point, it doesn't matter what server you use as long as you can retrieve data.
You can do it using Retrofit. For detailed instruction, check This medium post!

Send image via json in android

Hi I am working with android.I want to send an image from server to android and I had done it with sending url from server.How can I send an image from server to android app via json?? is it possible??
It is possible if you can convert your image at your server to a Base64 encoding string. Then you can send the string to your app via JSON.
You can use Apache Common IOUtils:
Base64.encode(FileUtils.readFileToByteArray(imageFile));
On your app you can convert the string to image, example in this link
How to convert a Base64 string into a BitMap image to show it in a ImageView?
Hope that helps
It is possible to send binary data within Json but you have to escape the binary data (UTF-8 encoding and use Base64.) This will increase the data size. Why not just include the path in JSON and fetch/load it?

uploading image file to server

I try to find way to send picture from android gallery to online database server such as mySQL , but I think I should upload this IMAGE file first to server after that getting the direct image link and send this link to database mysql
any one have simple idea about that ?
You could for example encode the image in Base64, and then send it to your backend parsed as JSON via rest webservices, and store it in a BLOB field.

Android to .NET image transfer using HTTP Get

I have successfully send a string from android to .NET using HTTP GET, I am using WCF in the .NET end, my real intention is to send an image from android mobile to .NET server, can I use GET for this, ie, convert the image into base64 string and then send the image to .NET just like I did for the string? If no, why is it not possible?
GET would append the Base64 encoded string representation of the image to the URL. URLs have length limitations hence the entire string may not get transferred.
A better approach would be to use POST with JSON data to hold the Base64 encoded image string.

How to upload image from Android device to Rails server?

I am working on a Android project and want to upload Bitmap images to my rails server. But I have no idea how to write the Rails models or controllers.
I find someone using MultipartEntity post to upload images and paperclip to recieve images on RoR server. I want to know how to connect the post and server (what url?) and how to write the model or controller.
I use a stupid method. I convert the Bitmap image to byte array and use Base64 method to convert it to a string. Post the string to server. When I want to get image, download the string and convert it to Bitmap.

Categories

Resources