Skip to main content

An issue with uploading to S3 with jquery file upload

Rails • Asked by Taro Singh

Hey guys, this is driving me crazy. I'm pretty new to rails and I have been following the shrine & S3 videos using the cloud based ide c9. I got basic direct uploads to work flawlessly, but when I introduced jquery file upload on image attachment, chrome console returns after the add call.
There's probably something I'm not fully understanding here, can anyone guide me in the right direction?


Hi Taro, did you find a solution to this? Think I'm getting the same issue - so frustrating!


Hey Adam,
I did find the solution,

Firstly I did not include any stuff for shrines presign plugin. So based off this it would be
Shrine.plugin :presign_endpoint in the Shrine.rb file
then
mount Shrine.presign_endpoint(:cache) => "/YOUR MODEL HERE/upload/cache/presign" in your Routes.rb
then changing

$.getJSON("/YOUR MODEL HERE/upload/cache/presign", options, function(result) {
              console.log("presign", result);
              data.formData = result['fields'];
              data.url = result['url'];
              data.paramName = "file";
              data.submit()
          });

in the uploads.js file

Unless I'm forgetting something that should be the fix, let me know! But now I'm getting an issue where my form only uploads the cache file, never the full image and the form never submits.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.