Storing image's as blob in mysql database with flutter - php

Is it good to store blob images in mysql database and fetch them in the flutter app using php or should I store them in a separate folder with their links in database? For a database with above 100K images what would be a better solution. Storing image paths would be difficult while backup i think. Can someone suggest what to do. It will be very helpful. Thank you in advance!

The best practice is to store the images in a folder and just save their path's in the database. So basically convert the images to base64 and send it to your webserver in a regular POST method. then in your PHP code decode the base64 to a file and save the image wherever you want, just remember to keep track of the image new path so can fetch it later. fetching, by the way, works the same. good luck :)

Related

Column Types for 64 Encoded Image via Laravel Migration

$table->text('company_logo')->nullable();
I'm trying to create a migration to store Base 64 Encoded image in my My SQL database. I'm not if what I have is good enough.
Is what I have good enough ? How do I know it ?
Storing any binary data (including images) in DB is a bad practice. You should save uploaded images as files and store links to them in DB.
its a bad idea to store images in database. it would be better if you save only path to you image in db. when you fetch the post data, you can just decode your base64 image, move this image to your images directory and save only the path to this image in database(for example /img/mypic.jpg)

Store an image in MySQL database and display it in ImageView in Android?

I am new to Android development. I am just trying to store an image in MySQL database and want to display that image in an ImageView.
What should I do?
I think I have to store the URL of image in MySQL database but I don't know how to do it either.
I am using PHP too.
One method is to store the base64 version of image using a php script with
base64_encode() wich returns the base64 encryption of the image but i don't recommend it because this is increasing the size of the image.
You should upload the image to a server and only store in the database the path to the image and then load it inside the Android application.
Here is a nice Java tutorial that explains how to upload an image through HTTP http://www.jguru.com/faq/view.jsp?EID=62798 it should work for your application.
Try to avoid if you can, storing images in database (as it would increase the size)..
If you cannot avoid, try using BLOB in database.. as mentioned here.
NOTE: Also do some research before asking questions.

Storing image in database vs storing in file system

I am working on a online shopping website, it will have product images also. I have confusion regarding were i should store images. If I store these images in the database image url must be kept into the database and if i store image in blob format i have to decode it before using in php. Can anyone tell which one will be better choice?
I think the best solution is to keep the Database clean of any images. Below are number of reasons -
Database will soon start to grow
File system is good for storing files
You have put extra effort to decode them in PHP(Resource overhead)
Many databases I have studied keep the images in the File System (WordPress source)
Hope it helps

save facebook photo to mysql BLOB

Just a quick question I am wanting to allow users to link there facebook account to my new product, and I am wondering how do I take there facebook photo URL and save it as an image in BLOB formate for MYSQL
I am using this example to connect to Facebook
https://github.com/facebook/connect-js/blob/master/examples/jquery/login.html
and to send the image to my server I use the $.ajax formate to submit it to the core.php (I have not coded this yet, as I need to know the best way.
Well my first recommandation is to NOT store image data in your database unless you absolutely need that in your database backups. You will clutter your database massively. Instead, just get the url to the picture using the server-side $facebook class, and just "file_get_contents" it to your php memory.
Then dump it on disk and save a reference of that dumped image in your database. It will do much more good to your database this way.
Else, if you really want to save it to a BLOB, use the same method to fetch the image to memory and then use the hex() function to transform it to a textual representation that can be fit into an INSERT/UPDATE query...
Just save a reference to the location where Facebook stores the image. That way you can abuse their servers (which are very nice/fast) and just serve image tags that refer to their servers.
Also when you save images to a database you lose the native compression that you get when you save an image to the filesystem, so you bloat your data storage size for not much reason (backups are easier I suppose).

How to store image into binary form and how to retrieve that back?

The best way to store images into MySQL is by storing the image location as a character string.
If you need to manipulate the image, then, the best way is to copy the image as a binary.
How one can store images into binary form and how we can retrieve them back? I don’t know anything about this technique. Please tell me how we can do this.
Don't store images in the database. Store them in the filesystem, then store their relative paths in the database.
I've written some blogs on this (and have some data from SQL Server)
http://www.atalasoft.com/cs/blogs/loufranco/archive/2007/12/03/images-in-databases-part-i-what-to-store.aspx
http://www.atalasoft.com/cs/blogs/loufranco/archive/2007/12/04/images-in-databases-part-ii-web-images-are-random-access.aspx
http://www.atalasoft.com/cs/blogs/loufranco/archive/2009/10/26/more-on-images-in-databases.aspx
Basically,
Small images are ok to put in a blob
Large images are much better to put on the filesystem
Images in a blob are much easier to manage (transactions, backup, simpler code, access control)
Images on the filesystem will perform much better
Think about pulling some meta-data out of the image and storing in separate columns for filtering and sorting purposes.
Almost every professional enterprise system that needs to deal with a lot of large blobs has some way of putting them on the filesystem. The latest SQL Server even has a field type that will do it automatically (and then it's as easy to program and manage as a blob)
You can use the BLOB data type. Although I agree with #Ignacio Vazquez-Abrams, there are times where storing the image in the DB is best. I have done so in past with great results. As long as the files are not large then this is a good solution.

Categories