回形针在没有AWS的情况下工作,但是当我尝试使用S3存储时,它会中断。Rails - 回形针不适用于AWS
#production.rb
config.paperclip_defaults = {
storage: :s3,
s3_region: ENV["AWS_REGION"],
s3_credentials: {
# s3_host_name: ENV["AWS_HOST_NAME"],
bucket: ENV["S3_BUCKET_NAME"],
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
}
}
config.paperclip_defaults = { s3_host_name: "s3-us-west-1.amazonaws.com", }
# Added this line to fix: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
之前添加的最后一行我得到一个错误S3(The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
)。添加完文件后,文件将被上传到本地存储而不是S3。
我也尝试将这些添加到paperclip.rb,并带有不同的错误。当我添加的所有3条线我得到的错误Read-only file system @ dir_s_mkdir - /projects
#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-1.amazonaws.com'
的Gemfile:
gem "paperclip", "~> 5.0.0"
gem 'aws-sdk', '~> 2.3'
我也试过rake assets:precompile RAILS_ENV=production
这似乎并没有帮助
编辑: AWS_HOST_NAME:S3 -us-west-1.amazonaws.com
AWS_REGION:us-west-1
S3_BUCKET_NAME:基础图像-2
AWS_ACCESS_KEY_ID:...
AWS_SECRET_ACCESS_KEY:...
我设置IAM帐户,并创造了美西1区的桶。 S3上有什么需要添加权限吗?
我不明白为什么回形针在本地存放,使用了任何错误,或者如果配置是什么S3 ..
昨天是否发生过这种情况? –
它仍在发生。我不认为这与S3中断有关 – Adam12344
这是值得一试的。您是否好意添加您从S3接收到的错误消息?另外,您添加的最后一行,是否在第一个配置设置下添加了,在'production.rb'中? –