Well I finally was able to reproduce the infamous zero size error. I'm
not sure if it's the same one your talking about but if so I think I
have some more clues as to the cause and a possible workaround.
First, I didn't have any problems before when I save the new image via
the parent object via
house.images << new_image
# Saved via the parent
house.save
I also modified the attachment_fu a bit to accept .bmp files as images
and everything continued to work. When I removed the parent from the
save operation via
new_image.house = house
new_image.save
all the sudden the .bmp files stopped working with the zero size
error. So I started looking through the code and noticed that for some
reason the .bmp files are being sent as Files and not StringIOs. I
haven't looked into why one is a StringIO and the other is a File but
I'm guessing it has something to do with the content type and Mongrel.
Regardless if it's a file it took a different path through the code.
Here's the uploaded_data=(file_data) method where the the path split.
By adding in the read and commenting out setting the path I was able
to fix it on my machine.
def uploaded_data=(file_data)
return nil if file_data.nil? || file_data.size == 0
self.content_type = file_data.content_type
self.filename = file_data.original_filename if respond_to?
(:filename)
if file_data.is_a?(StringIO)
file_data.rewind
self.temp_data = file_data.read
else
self.temp_data = file_data.read
#self.temp_path = file_data.path
end
end
Unfortunately I don't know what repercussions the fix might have.
Could the prior posters with the error verify if this fixes the zero
size error? Remember to restart your server after the change.
I had a different, but maybe related, problem with attachment_fu on
XP. Coincidentally, I just sent an email to Rick about five minutes
ago.
To rephrase my email to him>>
I added this line of code at line 161 in attachment_fu.rb to fix a
problem on Windows machines where all incoming images are corrupted by
extraneous line-feed characters. I am developing on windows
currently, so this stung me.
At line 161 of attachment_fu.rb:
tmp.binmode
The binary mode issue on Windows is discussed on this wiki page:
http://wiki.rubyonrails.org/rails/pages/HowtoUploadFiles if you're
interested in more info. This should not harm the app on linux based
on my prior experience with this bug (in my previous photo handling
model). Thanks again,
Well I finally was able to reproduce the infamous zero size error. I'm
not sure if it's the same one your talking about but if so I think I
have some more clues as to the cause and a possible workaround.
How do you recreate this error? I would like to submit a patch to ruby
core
-=R