how to write an binary file to ftp

Net::FTP#putbinaryfile(binary_file, remotefile)

binary_file is not a local file from some directory,but a dynamic
generation from codes.

The above codes not work,how to write it to ftp?

My server does not support filesystem writing,so i can not store the
binary_file data as an image in the file directory,and then send the
image using Net::FTP#putbinaryfile method.
Could i send the binary_file directly using
Net::FTP#putbinaryfile(binary_file, remotefile)?

Looking at the source to net/ftp it doesn't look like putbinaryfile
can do that, however all putbinaryfile seems to do is open up the file
and pass it to storbinary, presumably you could pass any IO object (eg
a StringIO) to storbinary.

Fred

thanks,Fred.
But i get the ftppermerror when using storbinary and StringIO.

thanks,Fred.
But i get the ftppermerror when using storbinary and StringIO.

are you sure the specified user can upload files

########
Net::FTP.open('showreelfinder.com') do |ftp|
ftp.passive=true
ftp.login(name,password)
ftp.chdir('www.showreelfinder.com/web/site/temp/uploads/heywatch
/thumbnails')

 thumbnail\_file=StringIO\.new\(thumbnail\)
 ftp\.storbinary\("STOR"\+"\#\{thumb\_title\}",thumbnail\_file,1024\)

Looks like you are missing a space after STOR, you should probably
also make the chdir and absolute path.

Fred

are you sure the specified user can upload files
yes,i am sure

########
Net::FTP.open('showreelfinder.com') do |ftp|
� � � ftp.passive=true
� � � ftp.login(name,password)
� � � ftp.chdir('www.showreelfinder.com/web/site/temp/uploads/heywatch
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � �/thumbnails')

� � �thumbnail_file=StringIO.new(thumbnail)
� � �ftp.storbinary("STOR"+"#{thumb_title}",thumbnail_file,1024)

Looks like you are missing a space after STOR,

   thank,i will try.
you should probably

also make the chdir and absolute path.

  I am sure the following path is right

thumbnail_file=StringIO.new(thumbnail)

do i need to change the above like this?Because i think the thumbnail is
binary file.

thumbnail_file=StringIO.new(thumbnail.to_s)

thumbnail_file=StringIO.new(thumbnail)

do i need to change the above like this?Because i think the thumbnail is
binary file.

If you've got a string ruby doesn't care about what's in it (of course
exactly what that line should depends on what kind of object you
have). You wouldn't get a permission error if you got that wrong
though - you'd probably just upload junk

Fred

If you've got a string ruby doesn't care about what's in it (of course
exactly what that line should depends on what kind of object you
have). You wouldn't get a permission error if you got that wrong
though - you'd probably just upload junk

hi fred

  After add a blank character and change thumbnail to thumbnail.to_s,my
project works now.Thank you very much.