Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading Image to Amazon S3 in Rails Application
    primarykey
    data
    text
    <p>I need to test Image Upload to S3 Bucket. So, I know I can use Carrierwave and Carrierwave_direct or fog as mentioned here <a href="http://railscasts.com/episodes/383-uploading-to-amazon-s3" rel="nofollow">http://railscasts.com/episodes/383-uploading-to-amazon-s3</a> Basically the approach taken there is uploading it through HTML form.</p> <p>My requirement is just to have a sample script in my rails app to upload it to the S3 bucket. Hoe can I achieve this in my rails app.</p> <p>Updated Script :</p> <pre><code>require 'rubygems' require 'aws-sdk' s3 = AWS::S3.new( :access_key_id =&gt; 'some', :secret_access_key =&gt; 'some') (folder_name, bucket_name) = ARGV unless folder_name &amp;&amp; bucket_name puts "Usage: upload_file.rb &lt;FOLDER_NAME&gt; &lt;BUCKET_NAME&gt;" exit 1 end b = s3.buckets[bucket_name] Dir.foreach(folder_name) do |item| next if item == '.' or item == '..' basename = File.basename(item) o = b.objects[basename] o.write(:file =&gt; item) puts item end </code></pre> <p>Not working getting error</p> <p>/Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/core/managed_file.rb:27:in <code>initialize': No such file or directory - burney_falls.jpg (Errno::ENOENT) from /Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/core/managed_file.rb:27:in</code>open' from /Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/core/managed_file.rb:27:in <code>open' from /Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/s3/data_options.rb:138:in</code>open_file' from /Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/s3/data_options.rb:61:in <code>rename_file_to_data' from /Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/s3/data_options.rb:34:in</code>compute_write_options' from /Users/test/.rvm/gems/ruby-1.9.3-p362/gems/aws-sdk-1.8.1.1/lib/aws/s3/s3_object.rb:591:in <code>write' from app/uploader.rb:21:in</code>block in ' from app/uploader.rb:16:in <code>foreach' from app/uploader.rb:16:in</code>'</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload