Heroku 和 Carrierwave 不加载我的 s3 配置

发布于 2024-10-27 15:36:50 字数 624 浏览 1 评论 0原文

我在 Heroku 上有一个应用程序,它使用 Carrierwave gem 将图像上传到 S3。

我已经在名为 Carrierwave.rb 的初始化程序中设置了 s3 配置,

CarrierWave.configure do |config|
  config.s3_access_key_id = 'XXXXXXXXXXXXXXXXXXXX'
  config.s3_secret_access_key = 'XXXXXXXXXXXXXXXXX'
  config.s3_bucket = 'XXXXX'
  config.storage = :s3
end

这在我的本地计算机上的开发中工作正常,但是一旦我部署到 Heroku,我会收到以下错误

A Errno::EACCES occurred in events#update:

Permission denied - /app/public/uploads
/usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:243:in `mkdir'

显然它正在尝试写入只读且不选择的 Heroku 服务器调高我的 s3 设置。

有谁知道如何让 heroku 将我的文件发送到 s3?

I have an application on Heroku that uses the Carrierwave gem to upload images to S3.

I have set the s3 configuration in an initializer called carrierwave.rb

CarrierWave.configure do |config|
  config.s3_access_key_id = 'XXXXXXXXXXXXXXXXXXXX'
  config.s3_secret_access_key = 'XXXXXXXXXXXXXXXXX'
  config.s3_bucket = 'XXXXX'
  config.storage = :s3
end

This works fine in development on my local machine, however once I deploy to Heroku I get the following error

A Errno::EACCES occurred in events#update:

Permission denied - /app/public/uploads
/usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:243:in `mkdir'

Obviously it's trying to write to the heroku server which is read only and not picking up my s3 settings.

Does anyone know how I can get heroku to send my files to s3?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白云不回头 2024-11-03 15:36:50

来自 CarrierWave wiki:

Heroku has a read-only filesystem, so uploads must be stored on S3 and cannot be cached in the public directory.

You can work around this by setting the cache_dir in your Uploader classes to the tmp directory:

查看 https://github.com/jnicklas/rierwave/wiki 并滚动到标有“Heroku 上的 CarrierWave”的底部部分,看看他们是如何设置的。希望这对某人有帮助。

From CarrierWave wikki:

Heroku has a read-only filesystem, so uploads must be stored on S3 and cannot be cached in the public directory.

You can work around this by setting the cache_dir in your Uploader classes to the tmp directory:

Check out https://github.com/jnicklas/carrierwave/wiki and scroll to the bottom section labeled "CarrierWave on Heroku" to see how they set this up. Hope this helps someone.

一念一轮回 2024-11-03 15:36:50

您看过这个演示应用程序吗?

特别是上传的类此处

Have you looked at this demo app.

In particular the uploaded class here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文