user2530633
user2530633

Reputation: 413

How to use a zip file download in wicket for larger files?

I would like to donload the zip file which is as large as upto 50MB. Currently I am using following IModel Object's getObject method to return the zip file.

IModel fileModel = new AbstractReadOnlyModel() {
public Object getObject() {
   .....
   ZipOutputStream zip = null;
   FileOutputStream fileWriter = null;
   fileWriter = new FileOutputStream(destZipFile);
   zip = new ZipOutputStream(fileWriter);

   /*Add the zip file in the folder*/

   return new File(zipFilePath);
}

following is the download link

reportLink = new DownloadLink(this.getString("id.reportslink"),
                fileModel) {
            private static final long serialVersionUID = 1L;
}

Currently JVM heap size is 1GB and above code will get crashed if there are 20 users concurently downloading the files (Assuming 50MB each file). Can anyone please suggest, what would be best way implement the downloading file so that it will not get crashed even if number of users are upto 100 at a time.

Upvotes: 1

Views: 544

Answers (2)

Tom
Tom

Reputation: 4093

I would suggest you work with dynamic resources instead of a simple DownloadLink.

You would create your own implementation of AbstractResource in which you write the file into an OutputStream and then create a ResourceLink instead of a DownloadLink that points to that resource.

Have a look at chapter 13.6 in the Wicket Free Guide at https://wicket-guide.googlecode.com/files/Wicket%20free%20guide.pdf.

Upvotes: 2

papkass
papkass

Reputation: 1289

This suggests that you should flush the output stream after a given amount of data has been send.

Upvotes: 2

Related Questions