[英]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 ). jRecorder是一个用于音频录音( 文档 )的jQuery插件。 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).
该插件使用浏览器的Flash Player录制音频文件,并将该文件保存在浏览器临时文件中,当用户完成录制后,它将以POST的形式将文件发送到PHP服务器(一个php文件)。 However, I would like to modify the plugin to send the file to an Amazon S3 bucket using Ruby on Rails.
但是,我想修改插件以使用Ruby on Rails将文件发送到Amazon S3存储桶。
How would I go about sending the recorded file to [my-amazons3-bucket] in RoR? 如何将录制的文件发送到RoR中的[my-amazons3-bucket]?
Just change the host param in the plugin to point to a rails route that will accept the post. 只需在插件中更改主机参数以指向将接受该帖子的Rails路线即可。 Here is AWS Ruby Gem http://amazon.rubyforge.org/
这是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 因此,您将有一个控制器来接受发布,然后只需将发布的文件上传到S3存储桶
You can use Carrierwave with store option Fog. 您可以将Carrierwave与存储选项Fog一起使用。 You will need to initialize your bucket with aws credentials in uploader.
您将需要使用上载器中的AWS凭证初始化存储桶。
self.storage :fog
self.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'youraccesskeyid',
:aws_secret_access_key => 'yourawssecretaccesskey',
:region => 'yourbucketregion'
}
self.fog_directory = "yourbucketname"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.