S3憑據正確配置回形針在Heroku無法刪除圖像:可以上傳,但使用回形針和AWS S3
# production.rb (same in development.rb)
config.paperclip_defaults = {
:storage => :s3,
:path => 'photos/:id/:style/:filename',
:s3_credentials => {
:bucket => ENV['aws_bucket'],
:access_key_id => ENV['aws_access_key'],
:secret_access_key => ENV['aws_secret_key']
}
}
我看到在Heroku的UI設置環境變量,我可以上傳照片就好了。
然而,當我試圖摧毀生產給定的模型,我得到這個錯誤日誌中:
2016-01-14T15:48:48.079923+00:00 app[web.1]: Completed 500 Internal Server Error in 591ms (ActiveRecord: 60.3ms)
2016-01-14T15:48:48.082519+00:00 app[web.1]:
2016-01-14T15:48:48.082522+00:00 app[web.1]: AWS::Errors::MissingCredentialsError (
2016-01-14T15:48:48.082523+00:00 app[web.1]: Missing Credentials.
2016-01-14T15:48:48.082524+00:00 app[web.1]:
2016-01-14T15:48:48.082525+00:00 app[web.1]: Unable to find AWS credentials. You can configure your AWS credentials
2016-01-14T15:48:48.082526+00:00 app[web.1]: a few different ways:
2016-01-14T15:48:48.082526+00:00 app[web.1]:
2016-01-14T15:48:48.082527+00:00 app[web.1]: * Call AWS.config with :access_key_id and :secret_access_key
2016-01-14T15:48:48.082528+00:00 app[web.1]:
2016-01-14T15:48:48.082529+00:00 app[web.1]: * Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to ENV
2016-01-14T15:48:48.082529+00:00 app[web.1]:
2016-01-14T15:48:48.082530+00:00 app[web.1]: * On EC2 you can run instances with an IAM instance profile and credentials
2016-01-14T15:48:48.082531+00:00 app[web.1]: will be auto loaded from the instance metadata service on those
2016-01-14T15:48:48.082531+00:00 app[web.1]: instances.
2016-01-14T15:48:48.082532+00:00 app[web.1]:
2016-01-14T15:48:48.082533+00:00 app[web.1]: * Call AWS.config with :credential_provider. A credential provider should
2016-01-14T15:48:48.082533+00:00 app[web.1]: either include AWS::Core::CredentialProviders::Provider or respond to
2016-01-14T15:48:48.082534+00:00 app[web.1]: the same public methods.
這一切工作就好了當地太(顯然是在利用不同的S3桶)。有什麼問題?即使上傳工作正常,我爲什麼僅在生產中獲得AWS::Errors::MissingCredentialsError
?
你說得對,我是使用AWS SDK v2和根據[此線索](https://github.com/thoughtbot/paperclip/issues/2021),直到5.0.0才能使用Paperclip支持。謝謝! – tirdadc