Amazon S3的更改文件下载名 [英] Amazon S3 Change file download name

查看:182
本文介绍了Amazon S3的更改文件下载名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有存储在S3上使用GUID作为键名的文件。

I have files stored on S3 with a GUID as the key name.

我使用的是pre标识的URL下载按<一个href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html#RESTAuthenticationQueryStringAuth">S3 REST API

I am using a pre signed URL to download as per S3 REST API

我存储在自己的数据库中的原始文件名。当用户单击从我的web应用程序下载文件的我想回到原来的文件名,但目前他们所得到的是一个GUID 。我怎样才能做到这一点?

I store the original file name in my own Database. When a user clicks to download a file from my web application I want to return their original file name, but currently all they get is a GUID. How can I achieve this?

我的web应用程序是销售人员,所以我没有太多的控制做的response.redirects所有文件下载到Web服务器,然后将其重命名由于州长限制。

My web app is in salesforce so I do not have much control to do response.redirects all download the file to the web server then rename it due to governor limitations.

有一些HTML重定向,元刷新,使用Javascript可以使用吗?是否有某种方式来改变S3下载的文件名(我唯一能想到的是如何应对的对象到一个新的名称,下载它,然后删除它)。

Is there some HTML redirect, meta refresh, Javascript I can use? Is there some way to change the download file name for S3 (the only thing I can think of is coping the object to a new name, downloading it, then deleting it).

我想避免创建每个用户一个水桶,因为我们将有大量的用户,仍然无法保证每个文件,在每个桶将有一个唯一的名字

I want to avoid creating a bucket per user as we will have a lot of users and still no guarantee each file with in each bucket will have a unique name

任何其他的解决办法?

推荐答案

我猜你的十字架张贴了这个问题的亚马逊S3论坛,而是为他人着想。我想张贴的答案在这里:

I guess your cross posted this questions to Amazon S3 forum, but for the sake of others I'd like to post the answer here:

如果只有过一用户名每个S3对象,那么你可以设置你的S3文件中的内容处理标头设置下载文件名: 内容处置:附件;文件名= foo.bar

If there is only ever one "user filename" for each S3 object, then you can set the Content-Disposition header on your s3 file to set the downloading filename: Content-Disposition: attachment; filename=foo.bar

有关公平起见,我想提一提,那不是我提供在亚马逊论坛正确的答案,所有学分应该去科林·罗德; - )

For the sake of fairness I'd like to mention that it was not me to provide the right answer on Amazon forum and all credits should go to Colin Rhodes ;-)

这篇关于Amazon S3的更改文件下载名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆