I have a problem with saving an image as a BLOB to MySQL. I only know the HttpURLConnection method, and I don't know how to make it accept byte[]. I can however send string to MySQL tables. But I don't know how to send Android image. I want to save it as a BLOB.
Related
I would like to create an application which accepts image in android convert it to base64string. The resulting base64 string will be sent to the rest API where it is converted to byte array and store in SQL DB. Is this the best possible way to store image in SQL DB or there any other possibilities?
Better practice is to store the string of the location on the filesystem where the service that executes your database call is hosted. When you retrieve the 'image' you retrieve the location and use that to pull back the image from the file system rather than storing the entire binary on the database.
This is My way , I will just say in simple way .first i create global path like "yourpath/"
then I Get image from server and Store it in device storage in the global path
then I Store only image name like imagename.jpg to the sqlite
at last I use image name stored in sqlite and concatenate with global path to display images whenever I want
I have a web platform in which the user enters the data, which are stored in SQL database. Using restful services and json I send the data in my mobile application via http calls, and I save them in sqlite database. The above works perfect. Now I want to upload images in web platform (which will saved in a separate table in SQL server) and in continue I want to get the images in mobile app, in the way which I have done for other data. After a lot research in google I found the blob data type. So , if I save the images as blob in sql then how can I convert them as json objects? Moreover, I want to know if it is efficient.
two ways to do that ( Base64 and byteArray ) by using Gson or Jackson, your byteArray shall automatically be converted to string if the variable is declared as string.
i want to build an andoid app , which will upload the image to sqlserver
i know how to save using ftp server,but i dont want to do in that way
is there any way that i can save directly to sql server
Thanks for your time guys
If you really need to save files in the database SQL server has a column type varbinary for saving BLOB objects.
http://msdn.microsoft.com/en-us/library/ms188362.aspx
You can do it by BASE64 encoding, you will obtain a string that you'll can store it into a TEXT field in your SQL DB.
And when you want to read or view the image, you'll have only to decode the string.
Here I give you a very good tutorial of how to encode
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.
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.