• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

without creating ZIP file on server (hard disk) and give it to client (download)

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone,

I am having a requirement in which i will let users choose a list of files (using check box) and let him download all the files he selected to download by zipping them and show him the download prompt for Open/Save/Cancel.

I am able to do this by creating the zip file on the server hard disk and making use of this file and let the user to download the files, every thing is going fine. But i don't want to create a zip file on the harddisk, i want to create it on the fly and let user download the zip file, at any point of time there should be no .zip file on my server.

can anyone suggest me how to achieve this, can anyone help me in this regard.
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depending on how large the files are, this may not be a good idea. If the files are megabytes in size, for example, then this will take up a lot of memory and may negatively impact the overall performance of your web application. But if you don't think that this will be a problem, you should be able to accomplish this by passing a ByteArrayOutputStream into the constructor of the output stream object.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply stream the zip file to the response's output stream. Start like this:

Then write to the ZipOutputStream the same way you are doing it now. Don't forget to close it when you're finished.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic