Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

AWS Version 2 support - uninitialized constant Paperclip::Storage::S3::AWS #1764

Closed
fuzzyjulz opened this issue Feb 9, 2015 · 59 comments
Closed

Comments

@fuzzyjulz
Copy link

It appears that the latest version of AWS - version 2, is not compatible with paperclip. From the aws-sdk-ruby:

NameError: uninitialized constant AWS

If you receive this error, you likely have upgraded to version 2 of the aws-sdk gem unintentionally. Version 2 uses the Aws namespace, not AWS. This allows version 1 and version 2 to be used in the same application.
http://ruby.awsblog.com/post/TxFKSK2QJE6RPZ/Upcoming-Stable-Release-of-AWS-SDK-for-Ruby-Version-2

Is there a plan to do the upgrade?

@darylprickett
Copy link

In the meantime the readme should probably be changed from
gem 'aws-sdk', '~> 1.5.7'
to
gem 'aws-sdk', '< 2.0'

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

@hughevans
Copy link

How to switch to fog:

   config.upload_file_options = {
-    storage: :s3,
-    s3_credentials: {
-      bucket:            ENV['FOG_DIRECTORY'],
-      access_key_id:     ENV['AWS_ACCESS_KEY_ID'],
-      secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
+    storage: :fog,
+    fog_credentials: {
+      aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
+      aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
+      provider: ENV['FOG_PROVIDER'],
+      region: ENV['FOG_REGION'],
+      scheme: 'https'
     },
-    s3_headers: {
+    fog_directory: ENV['FOG_DIRECTORY'],
+    fog_file: {
       'Cache-Control' => 'max-age=315576000',
       'Expires'       => 10.years.from_now.httpdate
     },
-    url: ':s3_alias_url',
-    s3_host_alias: '/',
     path: 'files/:hash_:style.:extension',
     hash_secret: ENV['SECRET_KEY_BASE']
   }

@fuzzyjulz
Copy link
Author

Hmmm but that is just changing the implementation for the Fog one.

What is the recommended approach? I would have thought that using the official amazon SDK would be better. If not then is paperclip looking to drop direct support for s3?

jsh-c referenced this issue in bborn/communityengine Feb 19, 2015
@uberllama
Copy link

+1 for v2 aws-sdk support. A lot of work has gone into this release.

@kenn
Copy link

kenn commented Feb 26, 2015

👍 for aws-sdk v2

@abourquin
Copy link

👍

@0000marcell
Copy link

👍 for aws-sdk v2

@DavidMMelin
Copy link

👍

4 similar comments
@sambecker
Copy link

👍

@eduardohertz
Copy link

👍

@Fredar
Copy link

Fredar commented Mar 5, 2015

👍

@chirag7jain
Copy link

👍

@hectorpalmatellez
Copy link

👍

1 similar comment
@djdrzzy
Copy link

djdrzzy commented Mar 16, 2015

+1

@brettv
Copy link

brettv commented Mar 16, 2015

What do the project maintainers intend to do or recommend doing?. I don't
actually have a strong preference one way or the other. I just want to
know so I can plan accordingly.

On Mon, Mar 16, 2015 at 11:23 AM, Daniel Drzimotta <notifications@github.com

wrote:

+1


Reply to this email directly or view it on GitHub
#1764 (comment)
.

@rselk
Copy link

rselk commented Mar 16, 2015

👍

7 similar comments
@darcy-kudos
Copy link

👍

@gt-sdi
Copy link

gt-sdi commented Mar 16, 2015

👍

@gabskoro
Copy link

👍

@robertg
Copy link

robertg commented Mar 17, 2015

👍

@brunoluigi
Copy link

👍

@andrelaszlo
Copy link

👍

@betesh
Copy link
Contributor

betesh commented Mar 25, 2015

👍

@djvs
Copy link

djvs commented Mar 31, 2015

What on earth is going on here?

@ChihuahuaPunk
Copy link

👍

@djvs
Copy link

djvs commented Mar 31, 2015

Can you detect which gem version is present and then just change the implementation accordingly?

@maclover7
Copy link
Contributor

It's great to have everyone 👍 -ing, but would anyone want to submit a PR too for v2 support?

@xtagon
Copy link

xtagon commented May 22, 2015

@davetchen Did you mean you are able to use both v1 and v2 of the SDK in a project using Paperclip? I have a project using Paperclip and I'd like to use the v2 SDK for other purposes, but when I use the method you described to require both versions, Paperclip fails to generate a correct presigned POST when I do my uploads. I'm seeing the following error from S3

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
    ...redacted details...
</Error>

Any ideas? Is aws_v2 branch considered okay for production? I don't care what version Paperclip uses, I just want to be using v2 in the same project.

@davetchen
Copy link
Contributor

It is working for me in a project with both aws-sdk-v1 and aws-sdk-v2, but haven't tested all use cases. If you're using the version from source 'https://rubygems.org' then Paperclip will be using aws-sdk-v1. Which region is your S3 bucket in?

@xtagon
Copy link

xtagon commented May 23, 2015

Region is US-Standard. As far as I can tell, the only thing that doesn't work is generating presigned POST params with Paperclip. Maybe I can just rewrite my code to sign it with the SDK v2 directly. But I still need to test other important stuff such as #exists?

@xtagon
Copy link

xtagon commented May 23, 2015

My development environment was set up incorrectly and the problem was unrelated to Paperclip. Everything works now with both versions, sorry for the false alarm. :)

@davetchen
Copy link
Contributor

Sounds good @xtagon! Did you end up trying the aws_v2 branch?

@xtagon
Copy link

xtagon commented May 27, 2015

Haven't gotten around to it yet since v1 and v2 work fine side by side. I'll test it when I get a chance and report any issue if I find any.

@davetchen
Copy link
Contributor

@betesh : I've been using the aws_v2 branch in production for a couple weeks with no issues. Do you think it's ready for a PR?

@betesh
Copy link
Contributor

betesh commented Jun 5, 2015

@davetchen The problem is not all the tests pass. I just pushed a commit (after rebasing onto master) with one example of getting a few tests to pass when stubbing, but there's still a lot of work to be done on this end.

@davetchen
Copy link
Contributor

Understood, I'll take a look at your commit.

@davetchen
Copy link
Contributor

@betesh I'm trying to setup the testing as described here: https://github.com/thoughtbot/paperclip/blob/master/CONTRIBUTING.md

The 'bundle' command has been running for the last 3 hours ... do you have an easier way to set it up? To see what is going on I set DEBUG_RESOLVER=1 as per:
http://patshaughnessy.net/2011/9/24/how-does-bundler-bundle

it's still 'iterating'...

@betesh
Copy link
Contributor

betesh commented Jun 9, 2015

I just did a bundle update and it took a few minutes but nothing crazy. I don't recall this happening during the first bundle install either.

I didn't to an appraisal install--I figured once tests are passing with 1 Gemfile, I'll open up my branch to travis to get a first approximation of any issues, before trying to debug all Gemfiles locally.

@davetchen
Copy link
Contributor

I think the problem is trying to find the right version of the 'rubysl' gem. I'm using ruby-1.9.3 and trying to install

gem install rubysl -v '~> 2.0.12'

There is a conflict with 'rubysl-benchmark' which has a dependency on ruby-2. Which ruby are you using?

@betesh
Copy link
Contributor

betesh commented Jun 9, 2015

I'm using ruby-2.1.5

@davetchen
Copy link
Contributor

OK -- just switched to ruby-2.1.6 and now I can run the tests (that was easy). I'm seeing 40 or so failures in the S3 storage spec of the form:

rspec ./spec/paperclip/storage/s3_spec.rb:94 # Paperclip::Storage::S3 missing :bucket option raises an argument error
rspec ./spec/paperclip/storage/s3_spec.rb:116 # Paperclip::Storage::S3  uses the correct bucket
rspec ./spec/paperclip/storage/s3_spec.rb:120 # Paperclip::Storage::S3  uses the correct key
...

Will start looking at these.

@davetchen
Copy link
Contributor

Hi Betesh -- just wondering about the status of the pull request. Are there other actions that need to be taken?
-dave

@betesh
Copy link
Contributor

betesh commented Aug 3, 2015

Not in my opinion. In my last 2 comments on #1903 (#1903 (comment), #1903 (comment)), I asked for feedback on the 2 issues people were still discussing, but I have received no feedback.

I just rebased it onto upstream/master. Give Travis an hour or 2 and then if everything passes, I'm ready for it to be merged.

@betesh
Copy link
Contributor

betesh commented Aug 17, 2015

Is anyone planning on merging this?

@jferris
Copy link
Contributor

jferris commented Aug 18, 2015

@davetchen @betesh sorry for the delay here. We're running a little behind right now because of vacations, our company retreat, and some other distractions. We're not sure when we'll be able to look at this, but we haven't forgotten about Paperclip and we'll get it merged as soon as we can.

@davetchen
Copy link
Contributor

Thanks for the update. Moving forwards more and more folks will be wanting to standardize on using the aws-sdk-v2, both for accessing new regions and new services.

@rept
Copy link

rept commented Aug 23, 2015

👍

@josedonizetti
Copy link

any plans to have this merged?

@jyurek
Copy link

jyurek commented Sep 2, 2015

#1903 was merged just about 2 weeks ago.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests