Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > to store or not to store an image

Reply
Thread Tools

to store or not to store an image

 
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      03-29-2005
Hello all!

I am amazed how many posts I have read to store an image in SQL, and just as
many against it. So I learned how to store an image in a SQL db and retrieve
the image. A little tricky, but not too bad. But then I thought I wanted to
try the other way, by putting the file location in SQL and storing the actual
image in another directory.
I plan to have many images on my web application, up to as many as 5000.
Not to mention the other tables I will have, that will have just as many
records.
So I think I will go the old fasion route, and just put in the path in the
DB instead of the image.

Do I dare ask? What do you think is the best way to go?

Second thing is, I have found a ton of articles on how to store the image,
but can't find any that shows an example of just storing the file path. If
somebody would have an example of this, or point me in a direction, that
would be great!

Thanks for all your help!!!

Rudy
 
Reply With Quote
 
 
 
 
W.G. Ryan eMVP
Guest
Posts: n/a
 
      03-29-2005
Rudy - the problem with storing the images is that you don't know for sure
how big the thing could grow in most instance. Today 5,000 - tomorrow maybe
it turns into 10,000. It's a lot easier to buy network storage than to
accomodate the cahnge in the databse. + you can't use indexes on blob
fields. If you have 5,000 images, then I would avoid using Blobs - having
done it in the past. Let me put it this way - the benefit of being 'right'
about storing in the db is virtually indistinguishable from the benefit of a
network drive - at least as far as the end user goes. The cost of being
wrong about the db is very very high. So there's basically a lot of risk
for a very little upside. IMHO, the math doesn't add up. The exception is
cases where you absolutely don't want the images exposed to end users except
through your application and you store them in the db and then have an a33
load of security on the db. I did this at my former job w/ about 10,000
pdfs, peformance totally sucked but the images were confidential and were
accessed rarely - one thing I forgot to mention above is the frequency of
access. The less they are accessed, teh less of a risk with storing in the
db.

I'd definitely ask my DBA for his/her opinion on the subject too - mine
would probably say no way without a really compelling argument.

As far as storing paths goes, just store the path as a varchar and then use
a ExectueScalar command or fill a datatable and use either the File or
FileInfo class passing in the value to get the file reference.

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Rudy" <> wrote in message
news:77C3218F-65B0-41B2-9C34-...
> Hello all!
>
> I am amazed how many posts I have read to store an image in SQL, and just

as
> many against it. So I learned how to store an image in a SQL db and

retrieve
> the image. A little tricky, but not too bad. But then I thought I wanted

to
> try the other way, by putting the file location in SQL and storing the

actual
> image in another directory.
> I plan to have many images on my web application, up to as many as 5000.
> Not to mention the other tables I will have, that will have just as many
> records.
> So I think I will go the old fasion route, and just put in the path in the
> DB instead of the image.
>
> Do I dare ask? What do you think is the best way to go?
>
> Second thing is, I have found a ton of articles on how to store the image,
> but can't find any that shows an example of just storing the file path.

If
> somebody would have an example of this, or point me in a direction, that
> would be great!
>
> Thanks for all your help!!!
>
> Rudy



 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      03-29-2005
In addition to the variables W.G. Ryan mentioned, the size of the images is
also a factor in determining which technique is more performant.
In most cases I prefer saving to the DB, and the reasons are outlined in
this article:
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Rudy" <> wrote in message
news:77C3218F-65B0-41B2-9C34-...
> Hello all!
>
> I am amazed how many posts I have read to store an image in SQL, and just
> as
> many against it. So I learned how to store an image in a SQL db and
> retrieve
> the image. A little tricky, but not too bad. But then I thought I wanted
> to
> try the other way, by putting the file location in SQL and storing the
> actual
> image in another directory.
> I plan to have many images on my web application, up to as many as 5000.
> Not to mention the other tables I will have, that will have just as many
> records.
> So I think I will go the old fasion route, and just put in the path in the
> DB instead of the image.
>
> Do I dare ask? What do you think is the best way to go?
>
> Second thing is, I have found a ton of articles on how to store the image,
> but can't find any that shows an example of just storing the file path.
> If
> somebody would have an example of this, or point me in a direction, that
> would be great!
>
> Thanks for all your help!!!
>
> Rudy



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      03-29-2005
> Do I dare ask? What do you think is the best way to go?

In terms of performance, storing images in a database is a huge waste of
resources. Why? Because the file system is a database. And a database app
such as SQL Server uses the file system to store its data. So, let's take a
look at the flow when using a database and when not using a database:

File System Only:

1. File is fetched from file system.

Database

1. Network Connection is made to database
2. Query is sent to database
3. Database parses query.
4. Database file is fetched from file system.
5. Image is retrieved from database file
6. Network Connection is closed


--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Rudy" <> wrote in message
news:77C3218F-65B0-41B2-9C34-...
> Hello all!
>
> I am amazed how many posts I have read to store an image in SQL, and just
> as
> many against it. So I learned how to store an image in a SQL db and
> retrieve
> the image. A little tricky, but not too bad. But then I thought I wanted
> to
> try the other way, by putting the file location in SQL and storing the
> actual
> image in another directory.
> I plan to have many images on my web application, up to as many as 5000.
> Not to mention the other tables I will have, that will have just as many
> records.
> So I think I will go the old fasion route, and just put in the path in the
> DB instead of the image.
>
> Do I dare ask? What do you think is the best way to go?
>
> Second thing is, I have found a ton of articles on how to store the image,
> but can't find any that shows an example of just storing the file path.
> If
> somebody would have an example of this, or point me in a direction, that
> would be great!
>
> Thanks for all your help!!!
>
> Rudy



 
Reply With Quote
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      03-29-2005


"Kevin Spencer" wrote:

> > Do I dare ask? What do you think is the best way to go?

>
> In terms of performance, storing images in a database is a huge waste of
> resources. Why? Because the file system is a database. And a database app
> such as SQL Server uses the file system to store its data. So, let's take a
> look at the flow when using a database and when not using a database:
>
> File System Only:
>
> 1. File is fetched from file system.
>
> Database
>
> 1. Network Connection is made to database
> 2. Query is sent to database
> 3. Database parses query.
> 4. Database file is fetched from file system.
> 5. Image is retrieved from database file
> 6. Network Connection is closed
>
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> What You Seek Is What You Get.
>
> "Rudy" <> wrote in message
> news:77C3218F-65B0-41B2-9C34-...
> > Hello all!
> >
> > I am amazed how many posts I have read to store an image in SQL, and just
> > as
> > many against it. So I learned how to store an image in a SQL db and
> > retrieve
> > the image. A little tricky, but not too bad. But then I thought I wanted
> > to
> > try the other way, by putting the file location in SQL and storing the
> > actual
> > image in another directory.
> > I plan to have many images on my web application, up to as many as 5000.
> > Not to mention the other tables I will have, that will have just as many
> > records.
> > So I think I will go the old fasion route, and just put in the path in the
> > DB instead of the image.
> >
> > Do I dare ask? What do you think is the best way to go?
> >
> > Second thing is, I have found a ton of articles on how to store the image,
> > but can't find any that shows an example of just storing the file path.
> > If
> > somebody would have an example of this, or point me in a direction, that
> > would be great!
> >
> > Thanks for all your help!!!
> >
> > Rudy

>
>
>

 
Reply With Quote
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      03-29-2005
Hello all!

Thank you for the great response. WG, I'm with you. Coming from the
hardware side, my thought is if I get too deep, and found the DB solution
didn't work for me, it would be tough to get out. Access is also a huge
thing. Theese images will be accessed a great deal, so I know there is going
to be alot of traffic.

Steve, I read your atricle. As a matter of fact, that was the article I used
to learn how to store and retrieve images on the DB. Nice job, laid out very
nicely. The reason I was trying the image in the DB way, beacuse I was going
to have my website put up on the webfarm for a few months, until I have
enough revenue to set buy the servers and hardware to run out of my office.
I didn't want some guy at this place snooping aroundand looking at the
images. I could have the images stiored at my location, and still have SQL at
the web farm, but it seems clunky that way.

But now I think go into debt big, buy the hardware and run it out of my
location. So I think in my case, storing the file path is the way to go. the
oterway seems fine for security and low access, but for high access it just
seems easier to do it the other way.

Thanks again for all your time.

Rudy

"Kevin Spencer" wrote:

> > Do I dare ask? What do you think is the best way to go?

>
> In terms of performance, storing images in a database is a huge waste of
> resources. Why? Because the file system is a database. And a database app
> such as SQL Server uses the file system to store its data. So, let's take a
> look at the flow when using a database and when not using a database:
>
> File System Only:
>
> 1. File is fetched from file system.
>
> Database
>
> 1. Network Connection is made to database
> 2. Query is sent to database
> 3. Database parses query.
> 4. Database file is fetched from file system.
> 5. Image is retrieved from database file
> 6. Network Connection is closed
>
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> What You Seek Is What You Get.
>
> "Rudy" <> wrote in message
> news:77C3218F-65B0-41B2-9C34-...
> > Hello all!
> >
> > I am amazed how many posts I have read to store an image in SQL, and just
> > as
> > many against it. So I learned how to store an image in a SQL db and
> > retrieve
> > the image. A little tricky, but not too bad. But then I thought I wanted
> > to
> > try the other way, by putting the file location in SQL and storing the
> > actual
> > image in another directory.
> > I plan to have many images on my web application, up to as many as 5000.
> > Not to mention the other tables I will have, that will have just as many
> > records.
> > So I think I will go the old fasion route, and just put in the path in the
> > DB instead of the image.
> >
> > Do I dare ask? What do you think is the best way to go?
> >
> > Second thing is, I have found a ton of articles on how to store the image,
> > but can't find any that shows an example of just storing the file path.
> > If
> > somebody would have an example of this, or point me in a direction, that
> > would be great!
> >
> > Thanks for all your help!!!
> >
> > Rudy

>
>
>

 
Reply With Quote
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      03-30-2005
Hi W.G.

Could you please give me an example how you would use the file info class. I
would save the pics to something like c:mypics. How would I get the pic name
and so forth. Or if you know of a place that shows this. That would be
great!!!

Thanks for your help!!!

Rudy

"W.G. Ryan eMVP" wrote:

> Rudy - the problem with storing the images is that you don't know for sure
> how big the thing could grow in most instance. Today 5,000 - tomorrow maybe
> it turns into 10,000. It's a lot easier to buy network storage than to
> accomodate the cahnge in the databse. + you can't use indexes on blob
> fields. If you have 5,000 images, then I would avoid using Blobs - having
> done it in the past. Let me put it this way - the benefit of being 'right'
> about storing in the db is virtually indistinguishable from the benefit of a
> network drive - at least as far as the end user goes. The cost of being
> wrong about the db is very very high. So there's basically a lot of risk
> for a very little upside. IMHO, the math doesn't add up. The exception is
> cases where you absolutely don't want the images exposed to end users except
> through your application and you store them in the db and then have an a33
> load of security on the db. I did this at my former job w/ about 10,000
> pdfs, peformance totally sucked but the images were confidential and were
> accessed rarely - one thing I forgot to mention above is the frequency of
> access. The less they are accessed, teh less of a risk with storing in the
> db.
>
> I'd definitely ask my DBA for his/her opinion on the subject too - mine
> would probably say no way without a really compelling argument.
>
> As far as storing paths goes, just store the path as a varchar and then use
> a ExectueScalar command or fill a datatable and use either the File or
> FileInfo class passing in the value to get the file reference.
>
> --
> W.G. Ryan MVP (Windows Embedded)
>
> TiBA Solutions
> www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
> "Rudy" <> wrote in message
> news:77C3218F-65B0-41B2-9C34-...
> > Hello all!
> >
> > I am amazed how many posts I have read to store an image in SQL, and just

> as
> > many against it. So I learned how to store an image in a SQL db and

> retrieve
> > the image. A little tricky, but not too bad. But then I thought I wanted

> to
> > try the other way, by putting the file location in SQL and storing the

> actual
> > image in another directory.
> > I plan to have many images on my web application, up to as many as 5000.
> > Not to mention the other tables I will have, that will have just as many
> > records.
> > So I think I will go the old fasion route, and just put in the path in the
> > DB instead of the image.
> >
> > Do I dare ask? What do you think is the best way to go?
> >
> > Second thing is, I have found a ton of articles on how to store the image,
> > but can't find any that shows an example of just storing the file path.

> If
> > somebody would have an example of this, or point me in a direction, that
> > would be great!
> >
> > Thanks for all your help!!!
> >
> > Rudy

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
best way to store binary image data in a variable using image magick Jack Perl Misc 2 01-25-2008 10:59 AM
wx.Image: Couldn't add an image to the image list. Laszlo Zsolt Nagy Python 1 01-26-2005 09:55 PM
how to retrieve and store an image in MS SQL and asp.net? angus ASP .Net 2 05-20-2004 02:40 PM
how to convert WebControls.Image to a byte[] to store in DB? Jim Hammond ASP .Net 2 11-12-2003 06:29 PM
store image in DB or in file clark ASP .Net 4 08-01-2003 01:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57