AWS S3红宝石url_for响应头(自定义文件名和文件类型) [英] AWS S3 Ruby url_for response headers (custom file name and file type)

查看:275
本文介绍了AWS S3红宝石url_for响应头(自定义文件名和文件类型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这些都记录在 <一href="http://docs.amazonwebservices.com/AWSRubySDK/latest/AWS/S3/S3Object.html#url_for-instance_method" rel="nofollow">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.

这篇关于AWS S3红宝石url_for响应头(自定义文件名和文件类型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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