Request.raw_post data saving for image getting error

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

On 14 August 2010 16:12, Yogendra S. [email protected] 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

Chris M. wrote:

On 14 August 2010 16:12, Yogendra S. [email protected] 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
here 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 "