You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ch...@t-systems.com on 2014/04/14 12:11:06 UTC

Download byte array

Hello,

Iam using a FileResourceStream to download a file. This needs an File, which I create on the fly like this:

tempFile = File.createTempFile("SLA", ".xls");

InputStream data = new ByteArrayInputStream(ConsoleDataHandlerImpl.getInstance().getReportAsByteStream(beginDate,endDate));
Files.writeTo(tempFile, data);

It works fine. But the problem is that it save the tempfile in my tmp folder. Is there a RessourceStream in Wicket which can handle a byte array so that I don't need a tempfile?


Mit freundlichen Grüßen
Christoph Manig




Re: Download byte array

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Mon, Apr 14, 2014 at 2:03 PM, Carl-Eric Menzel <cm...@wicketbuch.de>wrote:

> You can use a org.apache.wicket.request.resource.ByteArrayResource
> instead - It's an IResource implementation that takes a byte array. You
> can then use the resource in a DownloadLink, for example.
>

ResourceLink would be simpler.
Christoph should already know that from the previous discussion.

Also see org.apache.wicket.util.resource.AbstractResourceStream. It has few
abstract methods, one of them -
org.apache.wicket.util.resource.IResourceStream#getInputStream.
Just return ByteArrayInputStream.


>
> Carl-Eric
>
> On Mon, 14 Apr 2014 12:11:06 +0200
> <Ch...@t-systems.com> wrote:
>
> > Hello,
> >
> > Iam using a FileResourceStream to download a file. This needs an
> > File, which I create on the fly like this:
> >
> > tempFile = File.createTempFile("SLA", ".xls");
> >
> > InputStream data = new
> >
> ByteArrayInputStream(ConsoleDataHandlerImpl.getInstance().getReportAsByteStream(beginDate,endDate));
> > Files.writeTo(tempFile, data);
> >
> > It works fine. But the problem is that it save the tempfile in my tmp
> > folder. Is there a RessourceStream in Wicket which can handle a byte
> > array so that I don't need a tempfile?
> >
> >
> > Mit freundlichen Grüßen
> > Christoph Manig
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Download byte array

Posted by Carl-Eric Menzel <cm...@wicketbuch.de>.
You can use a org.apache.wicket.request.resource.ByteArrayResource
instead - It's an IResource implementation that takes a byte array. You
can then use the resource in a DownloadLink, for example.

Carl-Eric

On Mon, 14 Apr 2014 12:11:06 +0200
<Ch...@t-systems.com> wrote:

> Hello,
> 
> Iam using a FileResourceStream to download a file. This needs an
> File, which I create on the fly like this:
> 
> tempFile = File.createTempFile("SLA", ".xls");
> 
> InputStream data = new
> ByteArrayInputStream(ConsoleDataHandlerImpl.getInstance().getReportAsByteStream(beginDate,endDate));
> Files.writeTo(tempFile, data);
> 
> It works fine. But the problem is that it save the tempfile in my tmp
> folder. Is there a RessourceStream in Wicket which can handle a byte
> array so that I don't need a tempfile?
> 
> 
> Mit freundlichen Grüßen
> Christoph Manig
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org