Perl 中的图标图像代理
我正在尝试找出为我们的网站列表提供图标文件的正确方法。基本上,列表的图标可以来自少数不同服务(Flickr、Picasa、Google 静态地图、我们自己的内部图像托管服务等)的图像文件。图标的 URL 存储在我们的数据库中,因此我想通过简单地调用以下命令来显示每个列表图标:
http://www.example.com/listing/1234/icon
目前我一直在使用 CGI.pm 重定向到正确的图标 URL,但是,我想要文件直接显示,无需进行 301 重定向。以下是我们一直在使用的代码:
my $url = "http://www.example-service.com/image-123.gif";
print $query->redirect(-url=>$url);
如果有任何关于如何更新它以通过代理提供文件而无需重定向用户的建议和代码示例,我将不胜感激。预先感谢您的帮助!
I'm trying to figure out the right way to serve icon files for our site listings. Basically an icon for a listing can come from an image file from a handful of different services (Flickr, Picasa, Google Static Maps, our own internal image hosting service, etc). The URL of the icon is stored in our database so I'd like to enable each listing icon to be displayed by simply calling:
http://www.example.com/listing/1234/icon
Currently I have been using CGI.pm to do a redirect to the correct icon URL, however, I want the file to be directly displayed without having to do a 301 redirect. Here is the code for what we've been using:
my $url = "http://www.example-service.com/image-123.gif";
print $query->redirect(-url=>$url);
I would appreciate any suggestions and code examples of on how I could update this to serve the file via proxy without having to redirect the user. Thanks in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 LWP 获取远程文件并将其打印出来。
或者,您可以为数据库编写一个触发器,当您添加新列表时,它会下载列表的图像并将其存储在 Webroot 中的某个位置或数据库本身中。
Use LWP to get the remote file and print it out.
Alternatively you could write a trigger for your database which downloads the image for the listing and stores it either in the webroot somewhere or in the database itself when you add a new listing.