【发布时间】:2025-12-09 03:50:02
【问题描述】:
你好,我已经包含了给定的代码
def store_s3(file)
# We create a connection with amazon S3
AWS.config(access_key_id: ENV['S3_ACCESS_KEY'], secret_access_key: ENV['S3_SECRET'])
s3 = AWS::S3.new
bucket = s3.buckets[ENV['S3_BUCKET_LABELS']]
object = bucket.objects[File.basename(file)]
# the file is not the content of the file is the route
# file_data = File.open(file, 'rb')
object.write(file: file)
# save the file and return an url to download it
object.url_for(:read, response_content_type: 'text/csv')
end
此代码在我的本地数据中正常工作存储在亚马逊中,但是当我在 heroku 服务器中部署代码时,我也在服务器上创建了变量。
这里有什么我遗漏的地方,请告诉我问题的原因。
【问题讨论】:
-
I had made variables on server too怎么样? -
我在任何地方都没有看到
S3_BUCKET_LABELS -
检查 heroku 日志中的确切错误
标签: ruby-on-rails amazon-web-services heroku amazon-s3