Rails 3 + Carrierwave + jQuery文件上传无法将图像文件上传到Openshift服务器

时间:2016-06-12 12:32:04

标签: jquery ruby-on-rails openshift carrierwave

我正在尝试将大小为3.7 MB的图像文件上传到Openshift服务器并获取所有时间503服务暂时不可用错误:

服务暂时不可用 由于维护停机或容量问题,服务器暂时无法为您的请求提供服务。请稍后再试。 webauto-webauto.rhcloud.com上的Apache / 2.2.15(Red Hat)服务器端口80

当我上传较小尺寸的图像时,一切都运行良好。 请给我一些建议如何解决这个问题?

class ImageUploader < CarrierWave::Uploader::Base

after :store, :delete_original_file
include CarrierWave::RMagick
storage :fog

def delete_original_file(new_file)

if self.version_name.nil?
  self.file.delete if self.file.exists?
end
end

def cache_dir
"#{Rails.root}/tmp/uploads/cache/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end


def default_url
"#{Rails.root}/public/thumbnail.png"
end


version :original do
process :resize_to_limit => [300, 300], :if=> :dealer_picture?
process :resize_to_limit => [1500, 1500], :if=> :picture?
process :watermark, :if=> :picture?

end

version :medium, :from_version => :original,:if=> :picture? do
process resize_to_limit: [600, 600]
process :watermark
end

version :thumb, :from_version => :medium,:if=> :picture? do
process resize_to_fill: [450, 300]
end



def extension_white_list
%w(jpg jpeg gif png)
end

def watermark
manipulate! do |img|
logo = Magick::Image.read("#{Rails.root}/public/watermark.png").first
img = img.composite(logo, Magick::SouthEastGravity, 25, 25, Magick::OverCompositeOp)
end
end

protected

def picture?(file)
model.class.to_s.underscore=="picture"
end

def dealer_picture?(file)
  model.class.to_s.underscore=="dealer_picture"
end
end

1 个答案:

答案 0 :(得分:0)

好的,所以我认为这是OpenShift默认配置的问题,我做了以下几点:

ssh your_user@your_domain.com
cat /etc/php.ini | grep upload_max
=> 878:upload_max_filesize = 2M

因此,您应该尝试查看2M以下的文件是否会上传,如果更大的文件破坏了应用,您应该尝试联系OpenShift支持或尝试https://stackoverflow.com/questions/tagged/openshift