Rails 个文件在制作时上传
Rails files upload on production
我尝试使用载波将图像上传到我的本地服务器,没有出现错误。
但是当我尝试在我的生产服务器上上传相同的图像时,我遇到了验证错误(文件类型和空字段表单)。
我也检查规则,在我的 public/uploads 中我设置了 777
它可以是什么?
class ApplicationUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg gif png)
end
def filename
if original_filename
@name ||= Digest::MD5.hexdigest(File.dirname(current_path))
"#{@name}.#{file.extension}"
end
end
def auto_orient
manipulate!(&:auto_orient)
end
version :admin_thumb do
process :auto_orient
process resize_to_fit: [100, 100]
end
version :category_thumb do
process :auto_orient
process resize_to_fill: [327, 258]
end
version :list_thumb do
process :auto_orient
process resize_to_fill: [150, 115]
end
end
我的载波上传器:
我已经用 yum install ImageMagic 修复了它
我尝试使用载波将图像上传到我的本地服务器,没有出现错误。 但是当我尝试在我的生产服务器上上传相同的图像时,我遇到了验证错误(文件类型和空字段表单)。 我也检查规则,在我的 public/uploads 中我设置了 777 它可以是什么?
class ApplicationUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg gif png)
end
def filename
if original_filename
@name ||= Digest::MD5.hexdigest(File.dirname(current_path))
"#{@name}.#{file.extension}"
end
end
def auto_orient
manipulate!(&:auto_orient)
end
version :admin_thumb do
process :auto_orient
process resize_to_fit: [100, 100]
end
version :category_thumb do
process :auto_orient
process resize_to_fill: [327, 258]
end
version :list_thumb do
process :auto_orient
process resize_to_fill: [150, 115]
end
end
我的载波上传器:
我已经用 yum install ImageMagic 修复了它