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

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

问题描述

我将文件存储在 S3 上,使用 GUID 作为密钥名称.

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

我根据 S3 REST API

我将原始文件名存储在我自己的数据库中.当用户点击从我的网络应用程序下载文件时我想返回他们的原始文件名,但目前他们得到的只是一个 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?

我的网络应用程序在 salesforce 中,所以我没有太多控制权来做响应.重定向所有下载文件到网络服务器,然后由于调控器限制重命名.

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

还有其他解决方案吗?

推荐答案

我猜你的交叉将这个问题发布到 Amazon 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 文件上设置 Content-Disposition 标头以设置下载文件名:

Content-Disposition: attachment; filename="foo.bar"

为了公平起见,我想提一下,在亚马逊论坛上提供正确答案的不是我,所有学分都应该归 Colin Rhodes 所有 ;-)

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天全站免登陆