You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by eugenebalt <eu...@yahoo.com> on 2011/08/17 20:04:50 UTC

How to avoid keeping files on the server with DownloadLink

Just one more question,

Is it possible to do a resource download from memory, *not* from a file on
the server?

I currently have a DownloadLink pointing to a generated file. That is fine,
but we have multiple files getting generated and residing on the server that
don't get cleaned up. We are interested in whether it's possible to do a
download purely from memory.

BTW, I am aware that DownloadLink has a method called
"setDeleteAfterDownload(true)", but that's not what we want. If we have
that, then the 2nd time the user clicks the same link, there's an error.

We want correct file download each and every time the link is clicked, we
just don't want server files getting created.

Thanks

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3750767.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to avoid keeping files on the server with DownloadLink

Posted by eugenebalt <eu...@yahoo.com>.
Never mind, I found out -- override "protected void setHeaders(WebResponse
response) " in ByteArrayResource.

OK, thanks, it's almost done, but there's still one issue.

It's working fine, but when I click the link the FIRST time, I get the
Open/Save As and when I click Open, Excel opens MyApp[1].xls.

Then when I click the SECOND time, I also get Open/Save As, and when I click
Open this time, Excel gives me this:

"MyApp[1].xls is locked for editing. Open Read-Only or Notify"

This never happened with the DownloadLink. With the DownloadLink, every
click was a valid Excel file open. Now, it looks like the local isn't being
released for some reason.

I have to either cancel or click Read-Only, and then on the next open it's
fine again. Very strange...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3751200.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to avoid keeping files on the server with DownloadLink

Posted by eugenebalt <eu...@yahoo.com>.
How do I set this header on a ResourceLink? (I know I can do it on a
WebResponse, but I'm not dealing with that here.)

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3751171.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to avoid keeping files on the server with DownloadLink

Posted by Martin Grigorov <mg...@apache.org>.
header: Content-Disposition

On Wed, Aug 17, 2011 at 10:35 PM, eugenebalt <eu...@yahoo.com> wrote:
> So the question is, how do we force the Save As dialog box, rather than
> immediately auto-transmit.
>
> I know the DownloadLink does it, but is there a way to accomplish it with a
> ResourceLink? Thanks.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3750998.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: How to avoid keeping files on the server with DownloadLink

Posted by eugenebalt <eu...@yahoo.com>.
So the question is, how do we force the Save As dialog box, rather than
immediately auto-transmit. 

I know the DownloadLink does it, but is there a way to accomplish it with a
ResourceLink? Thanks.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3750998.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to avoid keeping files on the server with DownloadLink

Posted by eugenebalt <eu...@yahoo.com>.
Thanks,

I was able to convert a DownloadLink to a ResourceLink (backed by a byte[]),
BUT that changed the behavior of the link.

Previously, all clicks on the DownloadLink would result in a Open / Save As
dialog box. This is what we want. The file type is MS Excel, and it was
offering to open or save the file.

Now, with the ResourceLink, it's a little different:

1) The Excel file opens immediately inside of IE, no prompts
2) If, from another browser/session, the link is clicked by another user,
there's an Excel error, "A document with the name 'localhost' is already
open"

The code:

ByteArrayResource bar = new ByteArrayResource("application/vnd.ms-excel",
generateExcelBytes()); //returns byte[]
ResourceLink exportLink = new ResourceLink("exportLink", bar);
add(exportLink);

Previously, with the DownloadLink, the code was:

DownloadLink exportLink = new DownloadLink("exportLink",
generateExcelFile()); //returns File
add(exportLink);

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3750974.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to avoid keeping files on the server with DownloadLink

Posted by Martin Grigorov <mg...@apache.org>.
maybe you need ResourceLink instead backed by ByteArrayResource

On Wed, Aug 17, 2011 at 9:04 PM, eugenebalt <eu...@yahoo.com> wrote:
> Just one more question,
>
> Is it possible to do a resource download from memory, *not* from a file on
> the server?
>
> I currently have a DownloadLink pointing to a generated file. That is fine,
> but we have multiple files getting generated and residing on the server that
> don't get cleaned up. We are interested in whether it's possible to do a
> download purely from memory.
>
> BTW, I am aware that DownloadLink has a method called
> "setDeleteAfterDownload(true)", but that's not what we want. If we have
> that, then the 2nd time the user clicks the same link, there's an error.
>
> We want correct file download each and every time the link is clicked, we
> just don't want server files getting created.
>
> Thanks
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-avoid-keeping-files-on-the-server-with-DownloadLink-tp3750767p3750767.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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