I try for two days to have my entire website surf the Internet through Heroku and Amazon AWS S3 (to store my images), but ... I can't do it!
To make things easier, I would like to use Heroku and Amazon AWS S3 with paperclip to upload an image and show it.
I followed a lot of tutorials, but this sums up everything I did: https://devcenter.heroku.com/articles/paperclip-s3
The boot system works well with the underlying repository on the local computer, but if I follow the tutorial and put this code in my environment, I have errors
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
, , , , ( Heroku).
:
develpment.rb:
Blabla::Application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
end
production.rb:
Blabla::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.assets.version = '1.0'
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
end
herocu config:
AWS_ACCESS_KEY_ID: AKI********************
AWS_SECRET_ACCESS_KEY: Aiqpdg******************
DATABASE_URL: **************************
HEROKU_POSTGRESQL_CYAN_URL: ***********************
KOIDEPLOY_TOKEN: ********************
S3_BUCKET_NAME: pylo*****
paperclip.rb:
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-west-2.amazonaws.com'
:
, :
ArgumentError in PhotosController
missing required :bucket option
respond_to do |format|
, "heroku open":
, :
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
, :)
:
AWS S3 eu aera.
, ,
: photo.rb:
class Photo < ActiveRecord::Base
has_attached_file :image
end
show.erb.html:
<% if @photo.image? %>
<%= image_tag @photo.image.url %>
<% end %>
