users@jersey.java.net

[Jersey] Re: Hot iostream for tar

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 22 Aug 2012 12:23:42 +0200

On Aug 17, 2012, at 4:37 PM, dloy <dloy_at_ucop.edu> wrote:

> Sorry, this may have been covered recently but I have not kept up with the list.
>
> My program creates large tar files (e.g. > 15G). I need the output stream to be a direct feed to the user while the tar is being created. Currently I create a tar file and then return the file. The problem is that the delay on the tar creation can be over 1 hour (especially using gz) and often times out - no activity on the connection while the file is being created.
>
> Is there a best practice for doing this?

InputStream, Reader, DataSource, StreamingOutput - those are the types you may want to consider returning from your method. Use of StreamingOutput may be most suitable/convenient for the task.

> How is the mime set?

Depends on the streamed content. You may use any type that matches your content.

> Can a dropped connection be detected?

With streaming output you should get an IO exception when trying to write to the provided output stream.

Marek