AWS S3红宝石url_for响应头(自定义文件名和文件类型)红宝石、自定义、文件名、文件类型

2023-09-11 10:02:16 作者:一剑一江湖

我只是想知道这是否是一个错误,我的错误或者有没有人成功地得到这个工作

I'm just wondering if this is a bug, an error on my part or has anyone managed to get this working

>irb
>require 'aws/s3'
>AWS::S3::Base.establish_connection!( 
    :access_key_id    => key,
    :secret_access_key => secret)

>AWS::S3::S3Object.url_for(
   filename, 
   bucket, 
   :use_ssl => true,
   :response_content_type=>'text/plain',
   :response-content-disposition=>'attachment; filename=text.txt'
)

这会吐出一个签名网址

我可以得到一个URL出了这一点,但:response_content_type &放大器; :响应内容处置选项似乎并没有做任何事情。

I can get a URL out of this but the :response_content_type & :response-content-disposition options don't seem to do anything at all.

这些都记录在 http://docs.amazonwebservices.com/AWSRubySDK/latest/AWS/S3/S3Object.html#url_for-instance_method

有没有人有运气,每个请求头添加这些?还是我做错了?

Does anyone have luck with adding these per request headers? Or am I doing it wrong?

修改我想通了:如果有人跑进相同的 - 需要正确的创业板不是AWS / S3的AWS-SDK(有两种漂浮在那里与pretty的大同小异code - 我认为后者是一个老版本)

EDIT I figured it out: If anyone runs into the same - require the right gem not 'aws/s3' its 'aws-sdk' (there are two floating around out there with pretty much the same code - I think the latter is an old version)

推荐答案

大家好回答我自己.. AWS-S3 是一个老版本的 AWS-SDK 。很多他们之间code只是,即使你掉了要求头的工作原理。使用 AWS-SDK 来解决这个问题。

Hi guys answering it myself.. aws-s3 is an old version of aws-sdk. Lots of code between them just works even if you swap the require header. Use aws-sdk to fix this problem.