attachment_fu on Windows?

My guess is it's the Ruby version and the temp file issue that is your
problem. I took the following steps and was able to get it to work on
Windows

1. Installed rmagick via the instructions on http://rubyforge.org/projects/rmagick/

2. Installed AttachmentFU via

    ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/attachmen_fu/

3. In C:\ruby\lib\ruby\1.8\tempfile.rb

      # Modified per http://blog.teksol.info/articles/2006/12/08/rmagick-and-jpeg-datastream-contains-no-image
      # for the "JPEG datastream contains no image" bug
      # @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|
File::EXCL, 0600)
      @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL|
File::BINARY, 0600)

You might also want to review http://clarkware.com/cgi/blosxom/2007/02/24
to see if you haven't missed anything.

Eric

How about rolling back to 1.8.4 just to verify whether it's the ruby
release?

I also encountered this problem with attachment_fu. I tested it with the tempfile patch as well.

Quite maddening actually since I don’t have a solution for it.

Adam

Jeff,

If you want, email me your zipped app and I'll check if it works in my
environment.

Eric

I'm stuck like everyone else on the "0" filesize. Everything else
seems to work however.

Here is a step-by-step blog post on how my dev environment is setup:

http://blog.72bit.com/2007/03/12/attachment_fu-on-windows/

Wes

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.

Eric

Hmm....

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,

Eric

Eric Northam wrote:

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 :slight_smile:
-=R