java webapp上传图片访问URL
我的网络应用程序允许最终用户上传图像。将图像保存到服务器后,即可在我的网站上查看该图像。为了使网络应用程序更容易扩展,我决定根据当前时间将上传的图像存储到不同的文件夹中,例如:
/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
这样就可以了。然而,最终用户的图像 URL 还将包含以下信息:
http://www.mywebapp.com/images/upload/2011/11/30/image1.jpg
这是不可取的。我想知道是否可以生成“2011/11/30/image1.jpg”的摘要,如“8faa6933ac54cd2ae5eb575d2d966a42.jpg”,将映射保存在某处,然后为最终用户提供
http://www.mywebapp.com/images/8faa6933ac54cd2ae5eb575d2d966a42.jpg
:进来后,我们从之前保存的映射中查找真实图像,并为真实图像提供服务。
是否可以达到上述目的?或者根本不相关。我在我的应用程序中使用 spring mvc。
谢谢您的宝贵时间, 乔治
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编写一个 servlet 来捕获这些 url 并将图像作为字节流传递给用户。
You could write a servlet that catches those urls and pass the image to the user as a byte-stream.