Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Help With Working Example? #108

Open
MagLoftMagazines opened this Issue · 16 comments

7 participants

Nick Martin Nathan Youngman Yuval Kordov Sheharyar Naseer trbartel John Small chrishawk
Nick Martin

Hey all, I've been struggling for days with Carrierwave and Carrierwave_direct and I just can't get it to upload to a specific S3 directory (each member of my application needs to be able to upload to their own directory).

Anyway, I've been looking at S3 Direct Upload but am a little hesitant to try it out, mainly because the documentation about persisting the data is not 100% clear to me (still earning rails and very new to javascript).

I was wondering if any kind soul out there could share a super simple example of how you use S3 Direct Upload to upload and save S3 file information on a model.

I do apologize if this is too noobish...

Nathan Youngman

Found this blog post on using S3 Direct Upload with Paperclip (we're currently using Paperclip, otherwise we'd probably go with Carrierwave also). Either way, it might help.

Yuval Kordov

That's my blog post. Let us know if you have any questions. :)

Sheharyar Naseer

@uberllama @nathany If you'd be kind enough, could you please put up a simple s3_direct_upload application as an example? I'm very new to Rails & Javascript and can't get it to work despite working on it for days. Most of us noobs would really appreciate your help. Thanks!

Nathan Youngman

@PsychoSherry Sorry, I don't have an application like that to share. I did write a little bit on the process we used. Not sure if that helps though.

Sheharyar Naseer

@nathany I got it to work. It seems that I've been having the same problem as this guy. Using the monkeypatch in the comments, it started working. Thanks anyways.

Sheharyar Naseer

@lifestylenetworker I don't know if you were able to complete your app, but this gem does need a simple working example. So I took the time out to make one. Just putting this here if any one needs it.

S3 Direct Upload Example

Yuval Kordov

Hey guys, I've been planning to make an example repo based off my blog post and still do. Out sick this week but will try and put one together soonoish.

trbartel

Has anyone gotten this to work with PUT the upload to an existing model record from the show page?

John Small

Mmm, it does not work. I get this error

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

I've got CORS set as suggested but no luck.

Yuval Kordov

Are you using callback_method: "PUT" in your form helper? The upload to S3 will always be a POST, but you need to amend your callback method to tell your Rails controller that you're updating a file, not creating one.

John Small

Ah, I was navigating to localhost:3000, but had 0.0.0.0:3000 set in my CORS configuration on the bucket. If I navigate to 0.0.0.0:3000, then I do see the progress bar going up, but then I get an error

POST https://{my-bucket-name}.s3-eu-west-1.amazonaws.com/ 400 (Bad Request)

And nothing is saved in the bucket.

John Small

I just changed my CORS configuration to allow access from http://localhost:3000, and I get the same problem.

Yuval Kordov

Try using * for your allowed origin on your dev bucket and see if it works.

John Small

OK I did that and it makes no difference. I'm still getting POST https://{my-bucket-name}.s3-eu-west-1.amazonaws.com/ 400 (Bad Request)

Though the progress bar does go up.

John Small

I went back to https://github.com/pjambet/direct-upload which is supposedly the basis of the s3_direct_upload gem. After fiddling about with different names for the exported AWS params, I got it working. Horray!

So it must be doing something that the s3_direct_upload isn't doing. But what could it be?

chrishawk

@JohnSmall could you be more specific about your fiddling? I'm running into the same issue on a new site, which is kind of odd because I've used this approach dozens of times successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.