在本地一切都按预期工作,我使用 :file 存储并且它正在工作。
但是我部署的版本使用 :fog 存储并且它不工作。每次我尝试在那里上传图片时,都会遇到以下错误:
Permission denied - /mnt/foo/releases/20130607190757/public/uploads
我的上传器配置如下:
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
我的初始化程序定义如下:
CarrierWave.configure do |config|
unless Rails.env.test?
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
config.fog_directory = Rails.configuration.fog_directory
config.fog_public = false
end
if Rails.env.test? or Rails.env.cucumber?
config.enable_processing = false
config.storage = :file
# We may want to changes storage to 'file' after initial testing
elsif Rails.env.development?
config.storage = :file
elsif Rails.env.staging? or Rails.env.pilot? or Rails.env.production?
config.storage = :fog
end
end
任何人都知道可能导致该错误的原因是什么?看起来它正在存储为文件,因为它显示了整个文件的路径。
问候