1

Is there a way to upload to s3 directly using carrierwave in my server? the problem is am trying to track my uploading progress in the frontend (angularjs) but it only tracks the part where the file is uploaded or copied to my server.

I don't want to use the client side to upload directly or use background jobs is there any way or a workaround?

Mohamed Anwar
  • 13
  • 1
  • 3

1 Answers1

1

You can use "fog-aws" gem if you want to upload to S3 using carrierwave.

Here's a link. Scroll down to Using Amazon S3 section for details.

Also, you can take a look at this question. It explains how to use fog to generate pre-signed URLs for direct uploads.

Bohdan Sviripa
  • 403
  • 5
  • 9
  • thanks for your replay, am already using fog but the file gets copied first to the server then it gets uploaded to s3 bucket ... but i want to upload the file directly to s3 skipping the part where it gets to be saved in the server . – Mohamed Anwar Feb 18 '19 at 13:08
  • In that case, please take a look at this [question](https://stackoverflow.com/questions/21461143/use-fog-with-ruby-to-generate-a-pre-signed-url-to-put-a-file-in-amazon-s3). It explains how to use "fog" to generate pre-signed URLs for direct uploads. – Bohdan Sviripa Feb 18 '19 at 13:22
  • yea thanks, but other than that there is no way to upload directly from the server? – Mohamed Anwar Feb 20 '19 at 14:30
  • I'm not sure. You may try to investigate `carrierwave` source code. Maybe you'll find a way to upload a file to s3 through fog from RAM. However, this doesn't sound like a good, scalable solution. – Bohdan Sviripa Feb 20 '19 at 14:45