Hi everyone, I would like to ask for advice on which approach to use.
I have a dbsql on a remote server on which I should save jpg/png and pdf files.
Currently for all the other information I write and read I use a php script (I use okhttpUtils2). What do you recommend me to do? Because I read that converting a jpg to base64 would be too heavy, as would uploading the jpg or pdf file directly to the db. Is there a way to make loading and reading these files easier?
Could postmultipart be the right way?
Thank you all
Using multipart post is another option. Usually it creates a temporary file and you need to copy to another location. It can be write into a new file with information from the original filename and file extension, do image manipulation such as image resizing, and so on. The code may be slightly more complicated.
You could dedicate a folder ( on server ) and insert the images.
For example, if you have an image like test.jpg, it is best to save the image in the dedicated server folder and the file name (test.jpg) in the db.
So that when you upload it you will have to read only the name from the db and take the photo from the folder giving the entire path where it is stored (https://xxxx.com/foto/test.jpg)
The size of data maybe slightly bigger than the original file name. That's all. If that not a concern, then there should be no problem.
Using multipart post is another option. Usually it creates a temporary file and you need to copy to another location. It can be write into a new file with information from the original filename and file extension, do image manipulation such as image resizing, and so on. The code may be slightly more complicated.
Thank you.
So I did a test, I convert my jpeg with Base64EncodeDecodeImage.Base64ImageToString. The only problem I encounter is that the string obtained is too large to put inside mysql. I'm definitely doing something wrong, but I don't understand how to make mysql accept it. Do I have to convert it some other way?
You could dedicate a folder ( on server ) and insert the images.
For example, if you have an image like test.jpg, it is best to save the image in the dedicated server folder and the file name (test.jpg) in the db.
So that when you upload it you will have to read only the name from the db and take the photo from the folder giving the entire path where it is stored (https://xxxx.com/foto/test.jpg)