简体   繁体   中英

How to upload a recorded audio file to Amazon S3 using jRecorder and Ruby on Rails

jRecorder is a jQuery plugin for audio recording ( documentation ). The plugin records an audio file using the browser's flash player and saves the file in a browser temporary file and when the user finishes recording, it sends the file as POST to a PHP server (a php file). However, I would like to modify the plugin to send the file to an Amazon S3 bucket using Ruby on Rails.

How would I go about sending the recorded file to [my-amazons3-bucket] in RoR?

Just change the host param in the plugin to point to a rails route that will accept the post. Here is AWS Ruby Gem http://amazon.rubyforge.org/

So, you would have a controller that would accept the post and then you would simply upload the posted file to your S3 bucket

You can use Carrierwave with store option Fog. You will need to initialize your bucket with aws credentials in uploader.

 self.storage :fog
    self.fog_credentials = {
      :provider               => 'AWS',
      :aws_access_key_id      => 'youraccesskeyid',
      :aws_secret_access_key  => 'yourawssecretaccesskey',
      :region                 => 'yourbucketregion'
    }
    self.fog_directory = "yourbucketname"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM