2

Does anyone have any sample code (preferrably in rails) that uploads to s3, using s3's servers.

Again, uploading directly to s3, where the actual upload/streaming is also preformed on amazon's servers.

Blankman
  • 259,732
  • 324
  • 769
  • 1,199

4 Answers4

3

Requirements:

  • Plupload, jQuery

Idea:

  • Authorize Upload via your app (sign it on server-side)
  • Use the signed request to upload the file to S3
  • Notify your app that the upload is done
  • Check whether S3 has received the file

I posted the code as a gist at https://gist.github.com/759939, it misses commments and you might run into some issues due to missing methods (had to rip it from our codebase).

stored_file.rb contains a model for your DB. Has many of paperclips helper methods inlined (which we used before we switched to direct upload to S3).

I hope you can use it as a sample to get your stuff running.

Marcel Jackwerth
  • 53,948
  • 9
  • 74
  • 88
  • Approximately 2-3 days of work some months ago. But happy to share it (I also submitted a patch to plupload because of issues I had during implementation). – Marcel Jackwerth Dec 30 '10 at 17:14
1

If you are using Rails 3, please check out my sample projects:

Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader

Sample project using Rails 3, Flash/Silverlight/GoogleGears/BrowserPlus and jQuery-based Plupload to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
0

To simply copy files, this is easy to use: Smart Copy Script into S3

jschorr
  • 3,034
  • 1
  • 17
  • 20
0

Amazon wrote a Ruby library for the S3 REST API. I haven't used it yet.

http://amazon.rubyforge.org/

Paul S
  • 1,424
  • 1
  • 14
  • 12