3

I have a bucket with arbitrarily named files and a ruby script that generates a signed URL that expires in 2 days but I need to add a content disposition header to correct the file name to the desired format.

abritrarily (with a primary key from a database) to prevent filename conflict

is it possible to change the URL to make it add the content disposition header without modifying the files content-disposition header and saving it on the bucket?

4

2 回答 2

2

如果您使用 AWS SDK for Ruby 中 AWS::S3::S3Object 类的实例方法url_for ( )您的Amazon S3对象生成预签名 URL ,则可选哈希允许您指定用于生成URL,其中包括所需的标头:optionscontent-disposition

: response_content_disposition (String) — 在返回的 URL 上执行 HTTP GET 时设置响应的 Content-Disposition 标头。

于 2012-05-01T12:35:22.050 回答
0

如果有人正在寻找 JavaScript 示例:

s3.getSignedUrl(
  'getObject',
  {
    Bucket: 'foo',
    Key: 'bar',
    ResponseContentDisposition: 'attachment; filename="bar"'
  },
  (error, signedURL) => {
    console.log(signedURL);
  }
);
于 2018-04-23T16:21:08.480 回答