Upload images on mysql - mysql

I am working on a social networking site and i would like some help. I want the users of the site to upload images on mysql database. (I am using jsp pages). Any ideas?

You can, although it's generally a bad idea.
It's better to store the images somewhere on your server and store the image's path in the database instead, where you can save it along with other data (e.g. information regarding the uploading user).
If you insist, store it using this type:
http://dev.mysql.com/doc/refman/5.0/en/blob.html
Here's an example.

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.

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

Dealing with mass images, some small - some large, in spring/java application using mysql

I was wondering what the best pattern was to handle the management of images these days when using spring/java and mysql.
I have several options. Some of the
images are just small avatars for
the users. Is it fine to put these
directly into mysql? Or use the file
system?
For the larger images, is file
system pretty much the only option,
and then use mysql to store the
location on the file system?
Where is a good spot to put them on
a linux server? /var/files/images?
Since the files are hidden from the
war deployment directory, what is
the best way to stream them? Use
some kind of a file output stream as
the response body for an http
request?
Also, do I have to develop all of
the file management stuff myself,
like cleaning up unused files and
the like?
What about image security? Some images should not be accessed by everyone. I think I'd need to use a separate url with Spring security checking the current user for this.
I'd appreciate advice on all of these questions. Thanks.
You could use MySQL, and that would have the advantage of centralization and easy cleanup, but IMHO it's a waste of the database's resources if you plan to scale.
For data like images where everything is public, consider something like Amazon S3 which allows you to serve images directly from S3's web servers. If you plan to host everything yourself, just serve from a directory. Just remember to turn directory listings off :)

whats best way to create documents Archive of images in the database's?

What is the best way to create an Archive of image documents in the database ?
Given we have about 2-10 million records and each record includes 2-4 images and about 20 text fields , what is the best way for create this archive so that we have good speed and high security for data?
Also, what database is good for this project?
Definitely use the file system as Minor suggested.
One option is SQL Server FILESTREAM. See http://msdn.microsoft.com/en-us/library/cc949109.aspx.
Use file system storage for archive image. You must save link in DB for the image file. And if you use a HTTP content you can use the cache proxy server such as Squid, Nginx, etc.
More questions for you:
How dynamic is the data? Do you store it once and never change it or it gets frequently changed?
Do you need versioning for the documents or the latest version overwrites the previous and that's it.
Are the documents always edited using one application or they can be changed outside (ex: using Word)
Are the documents related to other "non-document" data (database rows) or is it the only thing that you need to store?
File system won't offer any real security, so I would discount that straight off.
In Oracle there is built-in image support through the ORDImage type.
Check out Marcel's blog as he, and the Piction company, do a lot of work in this area and he has lots of useful material to download.
You can use control downloads. Look at http://kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/lang/en/