You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Benussi <ma...@hotmail.com> on 2004/12/01 15:22:54 UTC

RE: Where to store and how to retrieve Images for web app

John,

I have also had this issue, and I can come at the problem from a different 
angle.

I allow users to upload images, and they get persisted to the file system 
under a directory in the Web App. A pointer to the image also gets placed in 
mysql.

I will be migrating to storing the data in Mysql and at application startup 
I will write the data out to the filesystem for my files that reference 
them. My main reason for doing this is that in deployment I don't want any 
environment specific content being overwritten, or even having to worry 
about it. I know that I can safely clear out the Webapp directory and I know 
that my database is backed up (And therefore so are the images).

As a second point I would be interested to know if anyone has any code 
snippets to persist (Create and Read) the data to MySQl.


----Original Message Follows----
From: john.chesher@convergys.com
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Where to store and how to retrieve Images for web app
Date: Wed, 1 Dec 2004 09:23:05 -0500





My web app will have about 300 users, each of whom will be allowed to
upload a max of 5 images/digital pictures.  I am using the Struts-upload
package.  I considered storing the images in MySQL as blobs, but have read
lots of advice that this is more trouble than it's worth / overkill.
However, I am perplexed (I am a newbie) as to where I should store them on
the file system and then how I would retrieve them and get them displayed
in a browser.  What is a "best practice" for this?

It would be easy to store them in a subdirectory of the web app, which
would allow me to include them in my JSPs with a simple HREF tag.  However,
does this cause problems with the size of the web app, maybe the start-up
and reload speeds of the container, etc.?  I trialed this by storing 1500
images in myWebApp/Pictures, starting Tomcat and retrieving images with a
HREF tag in a JSP.  I didn't notice any impact on startup time or
performance, but I want to make sure I'm not missing some other problem...

If I store them in the filesystem outside of the web app directory
structure, I can't just refer to them in my JSPs with an HREF tag, right?
It would be more work to have an action servlet retrieve the image file and
return it to the browser in the response object.  That seems to be just as
much work as storing them in MySQL, so why not just use MySQL?   What are
your opinions?




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Where to store and how to retrieve Images for web app

Posted by Brady Hegberg <br...@bitstream.net>.
We've tried a couple different approaches.  One of them involves a
pass-through servlet that grabs the image from the filesystem and sends
it to the browser on request.  It works well, in some cases.  However it
seems to cause some problems with caching - reloading the page is slow
and causes the graphics to flicker.  I wonder if people have run into
the same problems with storing pictures in mySQL.

Another possibility that I've considered is to have a directory of
images on the filesystem and copy them into your app at deploy time.  As
images are uploaded they would be saved to the filesystem and then
copied to the app.

Does anyone know if there are advantages in particular app-servers to
keeping your graphics on the filesystem versus in the database?

Brady

> John,
> 
> I have also had this issue, and I can come at the problem from a different 
> angle.
> 
> I allow users to upload images, and they get persisted to the file system 
> under a directory in the Web App. A pointer to the image also gets placed in 
> mysql.
> 
> I will be migrating to storing the data in Mysql and at application startup 
> I will write the data out to the filesystem for my files that reference 
> them. My main reason for doing this is that in deployment I don't want any 
> environment specific content being overwritten, or even having to worry 
> about it. I know that I can safely clear out the Webapp directory and I know 
> that my database is backed up (And therefore so are the images).
> 
> As a second point I would be interested to know if anyone has any code 
> snippets to persist (Create and Read) the data to MySQl.
> 
> 
> ----Original Message Follows----
> From: john.chesher@convergys.com
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Where to store and how to retrieve Images for web app
> Date: Wed, 1 Dec 2004 09:23:05 -0500
> 
> 
> 
> 
> 
> My web app will have about 300 users, each of whom will be allowed to
> upload a max of 5 images/digital pictures.  I am using the Struts-upload
> package.  I considered storing the images in MySQL as blobs, but have read
> lots of advice that this is more trouble than it's worth / overkill.
> However, I am perplexed (I am a newbie) as to where I should store them on
> the file system and then how I would retrieve them and get them displayed
> in a browser.  What is a "best practice" for this?
> 
> It would be easy to store them in a subdirectory of the web app, which
> would allow me to include them in my JSPs with a simple HREF tag.  However,
> does this cause problems with the size of the web app, maybe the start-up
> and reload speeds of the container, etc.?  I trialed this by storing 1500
> images in myWebApp/Pictures, starting Tomcat and retrieving images with a
> HREF tag in a JSP.  I didn't notice any impact on startup time or
> performance, but I want to make sure I'm not missing some other problem...
> 
> If I store them in the filesystem outside of the web app directory
> structure, I can't just refer to them in my JSPs with an HREF tag, right?
> It would be more work to have an action servlet retrieve the image file and
> return it to the browser in the response object.  That seems to be just as
> much work as storing them in MySQL, so why not just use MySQL?   What are
> your opinions?
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
-- 
Brady Hegberg <br...@bitstream.net>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Where to store and how to retrieve Images for web app

Posted by Guillaume Cottenceau <gc...@mnc.ch>.
"Mark Benussi" <mark_benussi 'at' hotmail.com> writes:

> As a second point I would be interested to know if anyone has any code
> snippets to persist (Create and Read) the data to MySQl.

In the application we use at my company, we put images in a
postgres database and we have a servlet which can reply with
image content when giving a proper id.

-- 
Guillaume Cottenceau

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org