What is the Better Idea to store Images? - asp.net

What would be the better Idea to store Images ? Is it Database (or) any hosting ?
(or) Is there any other idea to store images using ASP.net.

The standard answer is to use both; database holds the location of the files and the file server holds the actual data.
The main advantages of doing this are listed in Store pictures as files or in the database for a web app?

If you are using SQL Server and version 2008 or higher then its worth to store image in file stream. It contains both advantage of storing image in files and database.
Here you can find more information about it from following links.
http://technet.microsoft.com/en-us/library/bb933993(v=sql.105).aspx
http://www.codeproject.com/Articles/128657/How-Do-I-Use-SQL-File-Stream
Regards,

Related

how to read data from sqlite database in phonegap?

i use phonegap for my application. i create sqlite database and copied it on memory card.
Is it possible to read data from the database on a memory card
thank you and sorry for my poor english.
No. You can't read the database from a custom path. The PhoneGap/Cordova expects the database to be in particular location. If not present, it will create a new database.
But you can move the content to the expected location and start working on it.
Some links to help are:
http://www.raymondcamden.com/2012/7/27/Guest-Blog-Post-Shipping-a-populated-SQLite-DB-with-PhoneGap
http://gauravstomar.blogspot.in/2011/08/prepopulate-sqlite-in-phonegap.html

Should we store data in database?

i'm asp.net beginner and currently working in "upload download file" project with asp.net and vb.net as code behind language (like skydrive's web).
what i'm want ask is about upload file in server, must we store path file, size, accessed or created date into database? as we know we can use directory listing in system.io.
Thanks for your help.
You definetly want to store the path of the file. You want a way to find the file ;) Maybe later you will have multiple servers, replication or other fancy things.
For the rest, it depends a bit on the type of website. If it's going to get high traffic then store it in the database, this will limit the number of IO call (very slow). Also, it'll be a lot easier to handle sorting and queries. (sort by date, pull only the read onyl files, ...).
Database will also help if you want to show history or statistique.
You can save file in some directory and can save path of that file in database. You can also store size and created date of that file in DB. But storing a file in DB is a bit difficult. Rather than save file in Directory and save path of that file in DB
you could store the file information in a database to built some extra features like "avoid storing duplicate files", because you are having a faster search in the database! if you search the filesystem always a recursive function call get started

where do i store large amount of images for a website

I am a novice when it comes to websites
i'm developing a website for a real estate company this site will have loads of pictures of houses for sale
i thought of storing the images in a database but i have been advised to use a folder instead
which would be the best method to use a database or folder considering that there will be images added to the site on a daily basis ?
thanks
It's best performance wise to use the filesystem, and safety-management wise it's better to use the DB (backups and consistency).
However, in SQL Server 2008, you can apply the FILESTREAM attribute to a varbinary column, and SQL Server then stores the data for that column on the local NTFS file system.
Read about FILESTREAM Storage in SQL Server 2008
Also refer to the following:
FILESTREAM Overview
Getting Traction with SQL Server 2008 Filestream
Personally I would add the images into the file system as adding them to a database will bloat the database and not give you any advantages over the file system.
When storing them in the file system, you can create folders based on a unique id linked to the record in the database. This then means that you can add any media types to this folder and then recall/display them based on the unique id. It also means that you can display multiple images by simply coding your system to display all images in the folder.
Also, look into a content delivery network (CDN) which will cache the images and give you better performance when it comes to loading speed.
Don't put them in a database, this is highly ill advised for performance reasons.
Store them in a folder, and store the location to the image in the database.
Store them in a folder. If you have lots of images, a strategy to create subfolders (id, hash, uuid, etc) will be helpful.
imagefolder
+--00
| +--00
| +--01
| ...
| +--FF
+--01
+--02

Storing and retrieving images in sql server 2005 in asp.net via c#

How do I store and retrieve images in sql server 2005 in asp.net with c#
You may store them as binary data.
You may write a module (derived from IHttpModule), register it for RequestBegin event.
When request come you may retrieve data from database, store it on disk with requested file name and
this image will automatically be returned by built-in IIS handler (which is written in native code and works very fast).
Here is a project that does just the thing. All you need to do is move the storing and retrieving logic into your ASP .Net application.
It is not recommended.
Best practice is storing meta-data (here meta-data is you image file name) inside database and sotre them on file-system (for example c:\images). Then when you need an image you can ask database for its name and retreive it from file-system.
This helps you to have a compact database and maintenance became easy. Handling large databases backup/restore is a headache.

storing image in Db using asp.net

Im developing art gallery which needs 1000s of images to be uploaded so inserting images in DB won't be feasible. so i want to give link of folder inside db where ultimately images should get stored. plz help.
so inserting images in DB won't be
feasible
Why? Works very nicely. Especially with 2008 where you then dump them into a file system store again transparently.
I have a datas store where I store about 500gb of binary information all stored within the database. No issue at all.
Actually if you are using SQL 2008 you can use the FileStream mechanism, which actually stores the images as files on disk, but can be returned in sql results, so the data is still relational.
But answer aside, there's nothing wrong with storing 1000's of images in the database. But worst case, just store the string link if you really want.. its just that process is a little archaic.
It all depends on the DB that you're using I suppose (you didn't mentioned which you're using)
You can always store a relative path to the image file.
For example you might store images at UNC location of: \\YOUR_SERVER\myApplication\images\image1.png
-> the relative path would just be \myApplication\images\image1.png
(By storing just the relative path to the file, you're isolating the possiblity that you might change the server location in future.)
If you are using Sql Server 2008, then checkout the FileStream feature. More background info here.
One of my sites stores all user uploaded images in sql server and it works great. The only problem I can see if you are using shared hosting where you don't get a large database. Otherwise I think its a great option.

Resources