This gem provides easy integration between redactor.js and Amazon S3 for rails applications
-
Add the gem:
gem 'redactor_s3'
-
Mount it inside your routes:
mount RedactorS3::Engine => "/s3"
-
Run the installer:
rails generate redactor_s3:install
Dont forget to edit the config file
To use it you need to render some hidden fields in the views where you will be using redactor
Example:
# edit.html.rb ... ... <textarea class="redactor"></textarea> <%= render 'redactor_s3/config' %>
You then need to configure your redactor instance in jquery:
# edit.js ... ... $("textarea.redactor").redactor({ ... ... imageUpload: $("#aws_endpoint").val(), uploadCrossDomain: true, uploadFields: { 'key': '#aws_key', 'AWSAccessKeyId': '#aws_access_key', 'acl': '#aws_acl', 'success_action_redirect': '#aws_success_path', 'policy': '#aws_policy', 'signature': '#aws_signature', 'Content-Type': '#aws_content_type' }, imageGetJson: $("#aws_files_path").val() });
You should now be good to go
This project rocks and uses MIT-LICENSE.