Better store images on server or image strings on database? - mysql

i'm developing an android app where the user can take a photo. The app will have to upload it. I'm new of servers/databases. What's better? Store the image file "image.jpg" on the server or store the image string, encoded with base64, in MySQL db?
Are there other strategies?
CONSIDER THAT i will have to reload the image to visualize it on the phone.

i think better way is to store the images in a folder on the server and store their link in database..
Reasons
1) Normally time required to perform file operations is less than time required to perform database operations.
2) Updating the image is easy because its stored in file system which prevents the update operation on database which takes more time.

I think it is not a good idea to store image string in database instead of just its path (image name). Store your image on server and its name or path in database. Because retrieving image string from db and creating image for it each time you need that image is expensive. So better store its name only in server.

Related

Managing Large Databases of Images

I started working on a side project during the night. And it requires me to use large amounts of images, similar to Instagram, what do you recommend using as a database for this?
Should I upload the file to a path and referenced it from the database? Or should I use another type of database and upload the pictures there?
Thanks
"Should I upload the file to a path and referenced it from the database" - yes. Storing objects in mysql like that as a blob is bad practice. Put them in a directory somewhere and reference the path from your database of choice.. mysql is fine.
It won't be a good idea to store image directly in DB. DB size will increase. DB Hit will increase. So better store image as file in server and store the reference path in DB.
For Detailed Info :- Storing Images in DB - Yea or Nay?

Is it bad to store images as Data URIs in a database BLOB?

I'm creating a mobile app that views articles. These articles are just simple html with a couple of images each. I am currently storing everything in a database. Later, I will need to save the articles locally to the device in an easy format. For this reason, I have opted to store the Base64 images within the database, using a Data URI Scheme (look here for info http://en.wikipedia.org/wiki/Data_URI_scheme).
My question is: is it okay to store this much data in one database entry? I have a table that is ONLY for these large records, with article meta data tables that point to these. Would it be better if I used TEXT fields, rather than BLOBs?
If it helps, I am using MySQL with the InnoDB engine.
Avoiding using the db to store images is a good practice, keeping the images in the db not only slows down your db performance it also increases it size and backups, if you are using cloud service then there is also the cost issue.
Use S3 or Azure for this purpose and have only the url of the images in your db.Files may be uploaded directly to to the storage service reducing load on your db server. The only thing left to do is for your mobile application to connect both this services(db and the Images service),i found this web tool to manage my mobile app db because it connect to my Images cloud service which is Azure but i think they also support Amazon S3.
Another option would be to store images in something like:
Amazon S3
and then just have a field in your database that stored the url for each image.
As long as you dont have a DB as big as facebook or similar it should be fine.
It is best to store just the path to the image and the image themselves in a folder.
hope that helps
You could also look into Azure Blob Storage. I've been using it and it's working very well.

which way is effective to store images into database using JSP through html?

I want to store images into database using java server pages or struts via html.
time complexity and space complexity should be as less as possible.
which way is effective to store images into database using java server pages through html?
how to do that too?
is there any simple coding using Struts 2.1 for this task
I don't know your exact need, but What I suggest is instead of storing images in DB, just store name of the images as say "abc.png" in table and store the actual image in one folder and make that image folder where you are storing as configurable in properties file.
Now you can read property file and get path then just give name of image like
pathYouGetFromProprtyFile + File.seperator + imageNameYouGetFromDB
Hope this helps.
I would suggest you to convert the image to bytearray or BLOB/CLOB data format and store it in database.
From web tier you can use fileupload to upload the image, store it in temp server location. Change it to ByteArray and save it in database either using JDBC or hibernate.
Hope it will help you!!!!

download image directory from server and store on iphone

I am trying to create a business directory application for my area, I am currently trying to create a sql DB with all of the realivant business information (name, address, opening hours etc). I am then plan to have a physical file directory where all logo images are stored, this directory will be stored somewhere on the server.
When the user starts the applicatoin they will be prompted to download all of the information on business listings (because its for a small community), I will then upload all of the data to the phone using NSURLConnection, the data will be Zlib NSData in the form of XML. I will store all of this data into coredata (which will act as the apps cache).
The next step is to download the directory of images I have stored on the DB.. but I have no idea on the best approach for this and would like some guidance, example code etc.
For instance would it be better to store the images into the sqlDB? I have read this is a bad idea so am trying the approach explained above.
I am still in the process of building the sqlDB but the difficulty I am having is comming up with a way to get the images onto the device and relate them to the correct business using an id field or something simlar.. or is there an easier way to do this?
any help would be appreciated.
Instead of storing the image directly in the DB, you could store the URL to access the image binary instead. This would maintain the relationship with the image without storing the large image data directly in the DB. You could then use the URL retrieved from the DB to download the image on the device and similarly store the path to the downloaded cached image in core data.

Storing image in image column of SQL Server. Is it beneficial than storing image in folder on website

I have to display images on website and I can store image in the folder on my website and also I can store the image in image column of SQL Server.
So which way of storing image is better : in folder or in Image column of SQL Server.
1. Which way of storing image and retrieving it is faster
With SQL Server 2008, while you can store BLOB data, it's best to avoid it. I've done it in the past, grudgingly, and it did have negative performance implications. Unless you have some constraint which prevents it, use the file system. That's what it's built for, and it's much faster.
As #Martin Smith pointed out you could use FileStream. We started storing our files using FileStream so that we could also add full-text indexing and allow the users to not only search the data, but the files on our site. It is also nice because we can easily move our files along with teh Database to other environments (Dev, Test).
nice file stream Article: Here
Also, please use varbinary(max) if you are going to store in the DB. The image column is going to be deprecated in future versions.
--S