【发布时间】:2014-06-15 07:34:46
【问题描述】:
我可以在我的本地机器上上传开发中的图片,但偶尔上传会在服务器上失败。
我的设置是 DigitalOcean 上的 rails droplet,几乎没有改变。也就是使用 Nginx 和 Unicorn。
这是日志的最后一部分:
I, [2014-06-15T07:19:14.456577 #17704] INFO -- : Started GET "/photos" for 99.28.124.182 at 2014-06-15 07:19:14 +0000
I, [2014-06-15T07:19:14.458123 #17704] INFO -- : Processing by PhotosController#index as HTML
I, [2014-06-15T07:19:14.537837 #17704] INFO -- : Rendered photos/index.html.erb within layouts/application (76.7ms)
I, [2014-06-15T07:19:14.540100 #17704] INFO -- : Completed 200 OK in 82ms (Views: 78.7ms | ActiveRecord: 1.0ms)
I, [2014-06-15T07:19:23.700892 #17645] INFO -- : Started GET "/photos/new" for 99.28.124.182 at 2014-06-15 07:19:23 +0000
I, [2014-06-15T07:19:23.703720 #17645] INFO -- : Processing by PhotosController#new as HTML
I, [2014-06-15T07:19:23.717503 #17645] INFO -- : Rendered photos/_form.html.erb (8.1ms)
I, [2014-06-15T07:19:23.717913 #17645] INFO -- : Rendered photos/new.html.erb within layouts/application (8.9ms)
I, [2014-06-15T07:19:23.720011 #17645] INFO -- : Completed 200 OK in 16ms (Views: 11.7ms | ActiveRecord: 0.5ms)
I, [2014-06-15T07:27:53.659373 #17704] INFO -- : Started POST "/photos" for 99.28.124.182 at 2014-06-15 07:27:53 +0000
I, [2014-06-15T07:27:53.661330 #17704] INFO -- : Processing by PhotosController#create as HTML
I, [2014-06-15T07:27:53.661460 #17704] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"[removed]", "photo"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x0000000138eba8 @tempfile=#<Tempfile:/tmp/RackMultipart20140615-17704-kpatwj>, @original_filename="IMG_0078.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"photo[image]\"; filename=\"IMG_0078.jpg\"\r\nContent-Type: image/jpeg\r\n">, "description"=>"", "show_on_slideshow"=>"0", "show_on_gallery"=>"0"}, "commit"=>"Create Photo"}
I, [2014-06-15T07:27:53.671946 #17704] INFO -- : Command :: file -b --mime-type '/tmp/91ff30d4faf0a3803148a98cb7ae142420140615-17704-f93sr9'
I, [2014-06-15T07:27:53.673477 #17704] INFO -- : Completed 500 Internal Server Error in 12ms
F, [2014-06-15T07:27:53.676652 #17704] FATAL -- :
Errno::ENOMEM (Cannot allocate memory - file -b --mime-type '/tmp/91ff30d4faf0a3803148a98cb7ae142420140615-17704-f93sr9'):
app/models/photo.rb:14:in `check_file_size'
app/controllers/photos_controller.rb:32:in `create'
这里的@photo = Photo.new(photo_params)是指第32行:
# POST /photos
# POST /photos.json
def create
hide_from_unauthenticated
@photo = Photo.new(photo_params)
respond_to do |format|
if @photo.save
format.html { redirect_to @photo, notice: 'Photo was successfully created.' }
format.json { render :show, status: :created, location: @photo }
else
format.html { render :new }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end
【问题讨论】:
标签: ruby-on-rails imagemagick paperclip