Image attachment - broken read

Hello,
I am working on Windwos XP and try to
send a mail with image attachement.

attachment :content_type => “image/jpeg”,
:body => File.read(“an-image.jpg”)
end

But it seems that the image is cat off
on read()… when I try to puts the read()
I can see only small part the actual image.

Whats wrong?

Tom.

Hi Tom,

Most likely you are running into a File IO problem with the Windows port
of Ruby. To check and see if you have the problem, try executing
File.read(‘somefile’).length on a file larger than 16k. If this is your
issue, you will get back a 16000ish length string.

The good news, there is a solution. Switch to the cygwin port of Ruby.
:slight_smile:

-jeremy

(here are some notes from the Windows port of Ruby)

  1. This version was compiled using Microsoft Visual C++, not Cygwin.
    As a result, some I/O functionality – particularly those involving
    the Unix fork() system call and pipes – will not work. The benefit
    of using MSVC is to have a more stable and reliable version of Ruby.

openbsdpl wrote:

Hello,
I am working on Windwos XP and try to
send a mail with image attachement.

attachment :content_type => “image/jpeg”,
:body => File.read(“an-image.jpg”)
end

But it seems that the image is cat off
on read()… when I try to puts the read()
I can see only small part the actual image.

Whats wrong?

Tom.