Hi, I am try to saving the request.raw_post in file and try to saving image as regular paperclip saving image... i m getting the error ''Errno::EBADF (Bad file descriptor):'' can anybody tell me how sorted out this. Thanks in advance -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 14 August 2010 16:12, Yogendra Singh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am try to saving the request.raw_post in file and try to saving image > as regular paperclip saving image... i m getting the error > ''Errno::EBADF (Bad file descriptor):'' > > > can anybody tell me how sorted out this.Please show us your controller code, and the code around where the EBADF exception was raised. As a wild guess, it sounds like you''re trying to pass request.raw_post directly into Paperclip, while Paperclip is expecting to get a TmpFile or StringIO object (as it would it you just passed the parameter containing the file). Chris -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Chris Mear wrote:> On 14 August 2010 16:12, Yogendra Singh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> �I am try to saving the request.raw_post in file and try to saving image >> as regular paperclip saving image... i m getting �the error >> ''Errno::EBADF (Bad file descriptor):'' >> >> >> �can anybody tell me how sorted out this. > > Please show us your controller code, and the code around where the > EBADF exception was raised. > > As a wild guess, it sounds like you''re trying to pass request.raw_post > directly into Paperclip, while Paperclip is expecting to get a TmpFile > or StringIO object (as it would it you just passed the parameter > containing the file). > > Chrishere are my controller code " name = "tmp_image.png" data = request.raw_post @file_content = File.open("#{RAILS_ROOT}/tmp/#{name}", "wb") { |f| f.write(data) } if data @photo = Picture.new(:image => File.new(@file_content)) @photo.save " -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.