Reputation: 871
My web application allows end users to upload image. After the image is saved to server, the image will then be viewable at my web site. To make the webapp easier to scale, I decide to store the uploaded image into different folder based on current time, like:
/images/upload/2011/11/30/image1.jpg
/images/upload/2011/11/30/image2.jpg
/images/upload/2011/12/29/image1.jpg
/images/upload/2011/12/29/image2.jpg
This is ok. However the image URL for end user will also include information like:
http://www.mywebapp.com/images/upload/2011/11/30/image1.jpg
which is not desireable. I am wondering whether it is possible to produce the digest for "2011/11/30/image1.jpg" as something like "8faa6933ac54cd2ae5eb575d2d966a42.jpg", save the mapping somewhere, and then serve end user with:
http://www.mywebapp.com/images/8faa6933ac54cd2ae5eb575d2d966a42.jpg
When the request for the image comes in, we look up the real image from the previously saved mapping, and serve the real image.
Is it possible to achieve the above? Or it is not relevant at all. I am using spring mvc for my application.
Thank you for your time, George
Upvotes: 0
Views: 383
Reputation: 12538
You could write a servlet that catches those urls and pass the image to the user as a byte-stream.
Upvotes: 1