Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

store image in database or in a system file? [closed]

Tags:

.net

sql

database

Exact Duplicate: User Images: Database or filesystem storage?
Exact Duplicate: Storing images in database: Yea or nay?
Exact Duplicate: Should I store my images in the database or folders?
Exact Duplicate: Would you store binary data in database or folders?
Exact Duplicate: Store pictures as files or or the database for a web app?
Exact Duplicate: Storing a small number of images: blob or fs?

I have to store user's profile image (100px * 100px) what is the best way to store it ? database or system file ? which one is better , faster ,safer ... ?

like image 439
Hannoun Yassir Avatar asked Apr 19 '09 20:04

Hannoun Yassir


People also ask

Should I store image in database or filesystem?

Generally databases are best for data and the file system is best for files. It depends what you're planning to do with the image though. If you're storing images for a web page then it's best to store them as a file on the server. The web server will very quickly find an image file and send it to a visitor.

Is it good to store image in database?

Storing images in a database table is not recommended. There are too many disadvantages to this approach. Storing the image data in the table requires the database server to process and traffic huge amounts of data that could be better spent on processing it is best suited to.

What is the best way to store image in database?

Answers. Hi, These two ways are both ok. My suggestion is to store images into sql database if there are no much more images, otherwise, it's better store them into file system because you can store them no matter how many there are.


3 Answers

SQL Server 2008 offers the best of both worlds.

like image 86
Anton Gogolev Avatar answered Oct 05 '22 03:10

Anton Gogolev


I am going to propose a third option, a third-party party place like Amazon S3 or Mosso Cloud Files. Both provide APIs that you can use to upload the file and both provide CDN capabilities so the files will load quicker then they would off your servers or pulling from your database.

This is a nice option because it is the best of both worlds. The downside of storing images in the database is that it is additional stress on your application and database servers (locating the file and pulling it) and it also causes your database to grow in size which can mean you will need more hardware earlier.

The downside of storing them in the file system is that you now have an issue with scaling as if you want to add additional web servers they would each need a copy of the image or you would need create a dedicated server for these images. Also, file system access could be a future bottleneck to worry about.

like image 33
James Avery Avatar answered Oct 05 '22 03:10

James Avery


Always store images, music files etc in system files on disk, and then store the url:s to them in the database. That will make it

1) faster

2) easier to configure security settings

3) better in any ways I can imagine

like image 26
Tomas Aschan Avatar answered Oct 05 '22 03:10

Tomas Aschan