Wednesday, December 9, 2009

Errno::EACCES (Permission denied - Permission denied - Paperclip+Jruby+RMagick4j

If The issue Like:
===========================================================================================
Processing UsersController#upload_photo (for 125.18.56.182 at 2009-12-09 00:29:27) [POST]
Parameters: {"authenticity_token"=>"9w6TN5+/SsEp90euL2/qX/z+/v/RGkwPy7jKCmA1Z2A=", "user"=>{"photo"=>#}, "x"=>"31", "y"=>"16"}
User Load (3.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 29) LIMIT 1
User Load (3.0ms) SELECT `users`.id FROM `users` WHERE (LOWER(`users`.`screen_name`) = 'shrii' AND `users`.id <> 29) LIMIT 1
User Load (3.0ms) SELECT `users`.id FROM `users` WHERE (LOWER(`users`.`email`) = 'shrikant.lokhande@betterlabs.net' AND `users`.id <> 29) LIMIT 1
User Update (2.0ms) UPDATE `users` SET `photo_file_name` = '3d_animals_11.jpg', `photo_content_type` = 'image/jpeg', `photo_file_size` = 0, `non_login_key` = '7276c63c3af812a1d7b9dca628e27f437b8003dc', `updated_at` = '2009-12-09 05:29:28' WHERE `id` = 29
[paperclip] Saving attachments.
[paperclip] saving /mnt/assets/3d_animals_11.jpg

Errno::EACCES (Permission denied - Permission denied - /tmp/3d_animals_11,12625,3937.jpg or /mnt/app/3d_animals_11.jpg):
/opt/jruby/lib/ruby/1.8/fileutils.rb:505:in `mv'
/opt/jruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
/opt/jruby/lib/ruby/1.8/fileutils.rb:1411:in `fu_each_src_dest0'
/opt/jruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
/opt/jruby/lib/ruby/1.8/fileutils.rb:494:in `mv'
app/controllers/users_controller.rb:72:in `upload_photo'
====================================================================================

FIX is :
vi rails/vendor/plugins/paperclip/lib/paperclip.rb

-----------------------------------
def flush_writes #:nodoc:
@queued_for_write.each do |style, file|
file.close
FileUtils.mkdir_p(File.dirname(path(style)))
log("saving #{path(style)}")
# FileUtils.mv(file.path, path(style)) # Comment out this
FileUtils.cp(file.path, path(style)) # add this two line
FileUtils.rm(file.path) # this too.
FileUtils.chmod(0644, path(style))
end
@queued_for_write = {}
end
---------------------------------------
Its look like.

Its Worked for me. Cool.

1 comments:

Renu said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
Devops Training in electronic city