• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing Multiple image uploads  RSS feed

 
bin ber
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on my small project for school. One of the thing this application has to do is , get images uploaded by the user and show that as slide show later when some body see's what is uploaded.

Example: It can be my apartment or house images, if I want to rent it.So it has to show the images in slide show. But my question is not how to show in slide show but rather where to store the images?

I don't want to store it under my web application because It may be lost when I redeploy also need restart every time image is uploaded, I tried to save it in my hard disk but it looks like html img src "".. get resources only from the current web context or from some url like http://www.blabla.com/images but again I don't want to have another web application for image storing only. But it looks like that is how craigslist or some other sites work.

When I view the html source , I see something like src="http://image.craigslist.com" so can you please tell me best way to do it?

Storing the image as blob in DB is also another option but user may upload 100pics so don't want to do that in DB it will affect scalability of my project.Here are the technologies I am using Strus2,jsp,hibernate,html5 etc.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're on the right track storing them outside the web app. But the piece that you are missing is a servlet that can read the images from outside the web app and stream them to the client. Do a search for streaming servlet and you should find some examples.

Be sure to set the response headers correctly to identify the response as the appropriate content type.
 
bin ber
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear really appreciate that.I can stream it but here are the reason I don't want to do that

1. I prefer passing meta data ( location of the image file) instead of streaming it , which makes is more faster by avoiding latency (streaming through the wire).

2. The images will be show as slide show when the user clicks an Image link,.so when user click link I just want to pull the images from where it is stored instead of calling servlet back and set response object and coming back.
I also want to show it as slide show.

3. Finally I am thinking to go with storing it some where may be Amazon S3? what do you think? I really want to know how facebook,craigslist,google plus etc works? Where they store users album and show as slide ?That is similar thing I want to do.

Very Much appreciated.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order for the browser to get at images directly (like if you were using a JavaScript slide show widget) you'd need to store them in a public directory somewhere. Functionality-wise it doesn't matter much whether it's the same server where the web app lives, or some other server like Amazon S3. (There are of course other factors to consider, like storage cost, retrieval speed, integration into your web app, security etc.) But if this is for a school project, the easiest is probably to store them on the same server that your web app runs on, but in a public directory.
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't mean to muddy the water but another approach to this problem is to use a database.

Whether the database contains only metadata or metadata and the images is the subject for a good debate. There are pluses and minuses to bo both approaches and I can argue either side. In fact I have that argument with myself evreytime I need to store images in a database. My current project keeps the images in the database as binary blobs.

A slide show could then be a page with an icon link to the previous image, the current image and another link to the next image. The links and img tags are implemented as GET requests to a REST interface that sends just the image with the appropriate MIME type.

Joe
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bin ber wrote:1. I prefer passing meta data ( location of the image file) instead of streaming it , which makes is more faster by avoiding latency (streaming through the wire).

You can't avoid it. if the image is to be shown on the client, it must be sent to the client.

2. The images will be show as slide show when the user clicks an Image link,.so when user click link I just want to pull the images from where it is stored instead of calling servlet back and set response object and coming back.

"pulling the image" from where it is stored is going to involve streaming it to the client. Whether you have your servlet do it (so that the file can be stored anywhere) or whether you let the web server (Tomcat or whatever) do it by including the image in the web app is irrelevant. The image is still streamed to the client.

3. Finally I am thinking to go with storing it some where may be Amazon S3? what do you think?

The amazon servers are still going to need to stream the image to the client.
 
bin ber
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much guys for sharing your valuable information. I just registered here for sake of this question. But I will be here afterwards. Learned a lot from experts.Your response was so fast. I posted it a week ago on stack overflow but still only 40 views and 0 response.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!