Hello everyone,
I am trying zip files.
save_path_file = "/home/name/dest/zip/test.zip"
Zip::ZipFile.open(save_path_file, Zip::ZipFile::CREATE) { |zipfile|
zipfile.add(''test'',
"/home/my/file/destination/test.pdf")
}
I want to Zip folder. Problem is If folder contain only one pdf, it just
zipping file. while i extract the zipped file its not coming with folder
while zipping folder contain one file.
How can i achive folder zipping even one files.
Please help
Thank You!
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/rfUXJTHhcD0J.
For more options, visit https://groups.google.com/groups/opt_out.
On 6 February 2013 07:14, Saravanan P <saravanan.p-tks5Z7IV8F8RmelmmXo44Q@public.gmane.org> wrote:> Hello everyone, > > I am trying zip files. > > save_path_file = "/home/name/dest/zip/test.zip" > Zip::ZipFile.open(save_path_file, Zip::ZipFile::CREATE) { |zipfile| > zipfile.add(''test'', "/home/my/file/destination/test.pdf") > } > > I want to Zip folder. Problem is If folder contain only one pdf, it just > zipping file. while i extract the zipped file its not coming with folder > while zipping folder contain one file. > > How can i achive folder zipping even one files.Did you try the docs at http://rubyzip.sourceforge.net/classes/Zip/ZipFile.html? I have not used it but it looks as if the answer should be there. Also googling for zip::zipfile::create add folder shows lots of good looking hits Colin> > > Please help > > Thank You! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/rfUXJTHhcD0J. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hi Colin,
I solved that. Just I make a directory and add files into that.
*
*
*here my code:*
save_path_file = "/home/name/dest/zip/test.zip"
folder_path = "/path/to_/folder_name"
Zip::ZipFile.open(save_path_file, Zip::ZipFile::CREATE) { |zipfile|
zipfile.mkdir("folder_name") unless
File.exists?("#{folder_path}")
zipfile.add(''test'',
"/home/my/file/destination/test.pdf")
}
Thank You!
On Wed, Feb 6, 2013 at 2:44 PM, Colin Law
<clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
> On 6 February 2013 07:14, Saravanan P
<saravanan.p-tks5Z7IV8F8RmelmmXo44Q@public.gmane.org> wrote:
> > Hello everyone,
> >
> > I am trying zip files.
> >
> > save_path_file = "/home/name/dest/zip/test.zip"
> > Zip::ZipFile.open(save_path_file, Zip::ZipFile::CREATE) {
> |zipfile|
> > zipfile.add(''test'',
"/home/my/file/destination/test.pdf")
> > }
> >
> > I want to Zip folder. Problem is If folder contain only one pdf, it
just
> > zipping file. while i extract the zipped file its not coming with
folder
> > while zipping folder contain one file.
> >
> > How can i achive folder zipping even one files.
>
> Did you try the docs at
> http://rubyzip.sourceforge.net/classes/Zip/ZipFile.html?
> I have not used it but it looks as if the answer should be there.
> Also googling for
> zip::zipfile::create add folder
> shows lots of good looking hits
>
> Colin
>
> >
> >
> > Please help
> >
> > Thank You!
> >
> > --
> > You received this message because you are subscribed to the Google
Groups
> > "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send
an
> > email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/rubyonrails-talk/-/rfUXJTHhcD0J.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
Regards by
Saravanan.P
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.