I''d like to add several separate files into a new Gzip file created within ruby. The code I''ve got at the moment is as follows: File.open(''coursework_submissions.gz'', ''wb'') do |f| gz = Zlib::GzipWriter.new(f) @student_list.each do |s| temp = File.open("#{s.student.student_no}", ''wb'') temp.write(s.submission) temp.close() gz.add(File.open("#{s.student.student_no}", ''r'')) File.delete("#{s.student.student_no}") end gz.close end However, this just produces a file, coursework_submissions.gz, containing a file, coursework_submissions with the text of the files I want to add contained inside. Where am I going wrong? Thanks everyone. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Martyn Jones wrote:> However, this just produces a file, coursework_submissions.gz, > containing a file, coursework_submissions with the text of the files I > want to add contained inside. Where am I going wrong?Gzip is not a container format. Usually one use TAR to pack multiple files/objects into one archive and than gzip it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2008/2/26, Joachim Glauche <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Martyn Jones wrote: > > > However, this just produces a file, coursework_submissions.gz, > > containing a file, coursework_submissions with the text of the files I > > want to add contained inside. Where am I going wrong? > > Gzip is not a container format. > > Usually one use TAR to pack multiple files/objects into one archive and > than gzip it.Hi, I also need to compress a folder containing several jpg files to a .zip file. I don''t want to generate a .tar.gz file, but a .zip file that standard windows users can open (I''m an Ubuntu user but my client is not). How can I do that? -- Jaime Iniesta http://jaimeiniesta.com - http://railes.net - http://pagerankalert.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 20 Mar 2008, at 22:24, Jaime Iniesta wrote:> > 2008/2/26, Joachim Glauche <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> Martyn Jones wrote: >> >>> However, this just produces a file, coursework_submissions.gz, >>> containing a file, coursework_submissions with the text of the >>> files I >>> want to add contained inside. Where am I going wrong? >> >> Gzip is not a container format. >> >> Usually one use TAR to pack multiple files/objects into one archive >> and >> than gzip it. > > Hi, I also need to compress a folder containing several jpg files to a > .zip file. I don''t want to generate a .tar.gz file, but a .zip file > that standard windows users can open (I''m an Ubuntu user but my client > is not). > > How can I do that?Use rubyzip (http://rubyzip.sourceforge.net/) or the command line version of zip (install it if needed using "sudo apt-get install zip"). Google around for some examples on rubyzip. Although I personally would prefer the command line calls. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, 2008-03-20 at 22:24 +0100, Jaime Iniesta wrote:> 2008/2/26, Joachim Glauche <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: > > > > Martyn Jones wrote: > > > > > However, this just produces a file, coursework_submissions.gz, > > > containing a file, coursework_submissions with the text of the files I > > > want to add contained inside. Where am I going wrong? > > > > Gzip is not a container format. > > > > Usually one use TAR to pack multiple files/objects into one archive and > > than gzip it. > > Hi, I also need to compress a folder containing several jpg files to a > .zip file. I don''t want to generate a .tar.gz file, but a .zip file > that standard windows users can open (I''m an Ubuntu user but my client > is not). > > How can I do that?---- probably something like (untested) system(''/usr/bin/zip tmp/some_archive.zip -i path/to/files/\*.jpg'') send_file "tmp/some_archive.zip", :type => "application/zip" Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---