Question

Am having project structure in eclipse as shown below (using struts ). I have to upload a lot of item images in WebContent/images . The volume of images can increase with time to somewhere around 10000 to 15000 . My question is that each time I would be deploying a war file on the server the old data would be over written and all of the uploaded images would be gone . So what is the best way to implement this upload thing . What I have think of is making a seprate images folder on the machine and create a sym-link to it in my server directory . But if there is any better option available , or even if someone can add some comments on my exiting solution it would be better .

Project Structure

Was it helpful?

Solution

Store the images on your machine. Let's say, /var/project/images. If you have multiple servers running you can add a mount point using for example nfs or cifs. Writhe a image servlet that returns the data from this location. Just add the servlet to your web.XML and use /resources/images/* as servlet location. You can then usethe path information to locate the image in /var/project/images/.

OTHER TIPS

You can use the Symbolic Links/ alias direcory of linux filesystem to do this [folder short cuts in windows]

keep all the images outside webapps, like

usr/local/tomcat/itemimage/

and create a alias directory(Symbolic Links- like folder shortcut in windows) to webapps/<application>/image direcory to link usr/local/tomcat/itemimage/

One Suggestion, If you are going to have a large amount image data, better to load directly into an Amazon S3 bucket. S3, is a “highly durable and available store” and can be used to reliably store application content such as media files, static assets and user uploads. It allows you to offload your entire storage infrastructure and offers better scalability, reliability, and speed than just storing files on the filesystem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top