2016-06-12 36 views
0

我試圖上傳大小的圖像文件3.7 MB到Openshift服務器,並得到所有的時間503服務暫時不可用錯誤:的Rails 3 + Carrierwave + jQuery的文件上傳失敗上傳圖像文件Openshift服務器

服務暫時不可用 由於維護停機或容量問題,服務器暫時無法處理您的請求。請稍後再試。 Apache/2.2.15(紅帽)服務器在webauto-webauto.rhcloud.com端口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 
+0

你是否在OpenShift提供的免費層? – torresomar

+0

我使用小型基礎設備,升級到Small.highcpu沒有幫助 – maricavor

+0

可以顯示.htaccess文件嗎?我認爲這可能是一個問題max_file_upload_size – torresomar

回答

0

好了,所以我覺得這是O​​penShift默認配置的問題,我做了以下內容:

ssh [email protected]_domain.com 
cat /etc/php.ini | grep upload_max 
=> 878:upload_max_filesize = 2M 

所以,你應該嘗試找出是否低於2M的文件將上傳,如果更大的文件打破應用程序,你應該嘗試聯繫OpenShift支持或嘗試https://stackoverflow.com/questions/tagged/openshift

+0

如果我使用Ruby on Rails,php.ini文件中的設置有什麼不同?我如何編輯php.ini文件? – maricavor

+0

@maricavor我認爲你需要sudo權限,所以你應該直接嘗試openshift支持 – torresomar

+0

我不能直接聯繫Openshift,我認爲它只適用於silver計劃用戶。對我來說,仍然很奇怪,我應該在Openshift上編輯我的Rails應用程序的php.ini文件。 – maricavor