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? -- Posted via http://www.ruby-forum.com/.
ftp api itself has binary mode ,but not support writing file which itself is initially binary data? -- Posted via http://www.ruby-forum.com/.
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)? -- Posted via http://www.ruby-forum.com/.
On Nov 8, 9:27 am, Guo Yangguang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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> > -- > Posted viahttp://www.ruby-forum.com/.
thanks,Fred. But i get the ftppermerror when using storbinary and StringIO. ######## 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) end ########### The thumbnail is binary file,so can i use the stringio? can you tell me the details? I can not find an good example in ruby document. Thank you very much! -- Posted via http://www.ruby-forum.com/.
On Nov 8, 2:47 pm, Guo Yangguang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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> > end > ########### > The thumbnail is binary file,so can i use the stringio? > can you tell me the details? I can not find an good example in ruby > document. > Thank you very much! > > -- > Posted viahttp://www.ruby-forum.com/.
> 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> www.showreelfinder.com/web/site/temp/uploads/heywatch/thumbnails > Fred-- Posted via http://www.ruby-forum.com/.
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) -- Posted via http://www.ruby-forum.com/.
On Nov 8, 3:48 pm, Guo Yangguang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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> thumbnail_file=StringIO.new(thumbnail.to_s) > -- > Posted viahttp://www.ruby-forum.com/.
> 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 junkhi fred After add a blank character and change thumbnail to thumbnail.to_s,my project works now.Thank you very much. -- Posted via http://www.ruby-forum.com/.