简体   繁体   English

Paperclip aws-sdk错误:未初始化的常量

[英]Paperclip aws-sdk error: uninitialized constant

I'm currently running into the uninitialized constant Paperclip::Storage::S3::AWS error when I attempt to upload files to my server. 当我尝试将文件上传到我的服务器时,我正在遇到uninitialized constant Paperclip::Storage::S3::AWS错误。 I understand this to be typically caused by running an older version of paperclip, before they added support for aws-sdk-v2. 我理解这通常是由于在添加了对aws-sdk-v2的支持之前运行旧版的回形针引起的。 The strange thing is that I'm running the latest paperclip version (4.3.1) which, according to its github page , includes aws-sdk-v2 support. 奇怪的是,我正在运行最新的回形针版本(4.3.1), 根据其github页面 ,它包括aws-sdk-v2支持。

Honestly, I'm not sure what more I can say about this. 老实说,我不确定我能说些什么呢。 I checked the error log and the above is the only complaint it has. 我检查了错误日志,以上是唯一的投诉。 Do I need to do anything special to run v2 with paperclip? 我是否需要做任何特殊的事情来使用回形针运行v2? Thanks to anyone who can shine any light onto this matter. 感谢任何能够对此事发表任何看法的人。

the issue is written here: 问题写在这里:

http://ruby.awsblog.com/post/TxFKSK2QJE6RPZ/Upcoming-Stable-Release-of-AWS-SDK-for-Ruby-Version-2 http://ruby.awsblog.com/post/TxFKSK2QJE6RPZ/Upcoming-Stable-Release-of-AWS-SDK-for-Ruby-Version-2

try to change your Gemfile to: 尝试将您的Gemfile更改为:

  gem 'aws-sdk', '< 2.0'

Figured it out with the help of some folks over at github. 在github的一些人的帮助下想出来了。 (See the thread here.) (见这里的主题。)

Basically it seems that paperclip 4.3.1 doesn't entirely support v2 yet. 基本上似乎回形针4.3.1还没有完全支持v2。 A week after it was released or so, a commit was pushed to the master that gets past this error. 在它被释放一周之后,一个提交被推送到主服务器,它已经过了这个错误。 It appears not to be perfect but here's how I made it work. 看起来并不完美,但这就是我的工作方式。

You can specify this particular revision of paperclip to bundler with the following line: 您可以使用以下行将此特定修订的paperclip指定给bundler:

gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68'

More information on this sort of thing can be found here. 有关此类事情的更多信息,请点击此处。

You will need to specify the REGION of your in your paperclip defaults. 您需要在回形针默认值中指定您的REGION。 This can be done by dropping a :s3_region=> 'us-west-2' (or whatever your region is) into your paperclip_defaults . 这可以通过丢弃来完成:s3_region=> 'us-west-2' (或任何你的地区)到您的paperclip_defaults Simply specifying the endpoint or host will not be enough. 仅指定端点或主机是不够的。 You can look yours up here. 你可以在这里看看你的

Also slightly confusing is the error message if the above isn't done properly: 如果上述操作不正确,错误信息也会有些混乱:

missing region; 失踪地区; use :region option or export region name to ENV['AWS_REGION'] 使用:区域选项或导出区域名称到ENV ['AWS_REGION']

  1. I couldn't get the recommended environment variable to work. 我无法获得推荐的环境变量。
  2. The :region option is somewhat misleading as it needs to be written :s3_region :region选项有点误导,因为需要编写:s3_region

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM