I've been saving binaries to my db and there doesn't appear to be a great issue. Saves checking permissions on directories and such like. The over head isn't that great and most db's store the binaries pretty much as the file system would.

Advantage
IMO the advantage of storing images in the db is that you centralise your data (in the case of product images and such like) and you can manage who, were and when saved what to where.


Additional
Using hibernate makes life very easy in terms of saving the data, as you can pass a form file and pass it to the hibernate layer as a byte array in a set method.


Disadvantage
Using this approach does mean you'll have to run an action to retrieve the image.


Overall i'd say avoiding the hassle of file permissions outweighs the cost of retrieving images from the DB. However if i were to be writing a photo sharing portal perhaps i would rethink, but i think i'd still decide to store in the data in a db,



On 12 Jan 2004, at 12:42, Patrick Scheuerer wrote:

Hi everybody,

A while ago i posted a question concerning file uploads. My initial idea was to save all uploaded files in a directory of the web application. Craig R. McClanahan replied to my post with the following very interesting comment (thanks Craig!):

Craig R. McClanahan wrote:
> * You are not guaranteed that a particular servlet container
> even *has* a concept of a directory in which the web app
> is deployed -- for example, even Tomcat can execute a webapp
> directly from the WAR file. When you do that, getRealPath()
> returns null instead of a pathname, and your calculations above
> will trigger a NullPointerException.
>
> * Even when you know that your apps are being deployed in unpacked
> directories, uploading things directly into that directory means
> you have to be careful about redeployment when you update the app
> -- the normal behavior of "delete the old directory and replace it
> with the new app" wipes out any uploaded files.
>
> I would recommend defining a directory somewhere in your server to hold the
> uploaded files for a webapp, and then pass the pathname of this directory to
> your app as a context init parameter or something like that. This approach
> deals with both of the problems identified above.


My question is, how can i specify such a directory outside my webapp root diretory so that my Action classes can still reference those files? Craig's idea about using a context init parameter sounds good but do i have to retrieve this parameter manually every time i want to use it?

Ideally i would like to specify the upload directory in a properties file and then use the value of this property to create a constant that can be used throughout the application. is this doable? if yes, how?

I'm also looking into storing the files in the database along with the meta information for the files. What are the pros / cons for this approach? At the moment there are about 100 files that i have to deal with and there are not a lot of new ones added. The file size ranges from some KB up to ca. 5 MB...

Any suggestions, tips and comments would be higly appreciated.

Thanks a lot,
Patrick





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to