-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Apparently my last post didn't have an interesting enough subject line so people weren't reading it. Here it is again. I'm trying to download lots of data from the database - much more than I want to build a ListModel of. So it seems Filedownload.save using a Reader is the way to go. Here's a simple example that doesn't seem to be working. Can a Zk techie please comment?
The version with a String works fine, the StringReader does not - it produces an empty file (even though the read method IS called). Am I not understanding how it's supposed to work?
<window> <button label="This works" onClick="doString()" /> <button label="This doesn't" onClick="doStringReader()" /> <zscript> doString() { Filedownload.save("This is a test", "application/notepad", "file.txt"); } doStringReader() { java.io.StringReader reader = new java.io.StringReader("This is also a test"); Filedownload.save(reader, "application/notepad", "file.txt"); } </zscript> </window>
Thanks.
/Daryl
I think this is a bug.
Report to http://sourceforge.net/tracker/?group_id=152762&atid=785191
I'm using the following to download pdf, txt, xls... and i think it will download anything if there is no a bug elsewhere:
...
java.io.InputStream is = new java.io.ByteArrayInputStream( rr.getData().getBytes() );
if (is != null){
String ext= ".txt";
if( rr.getData().getMimeType().toUpperCase().indexOf("PDF") >=0 ){
ext= ".pdf";
}else if( rr.getData().getMimeType().toUpperCase().indexOf("XLS") >=0 ){
ext= ".xls";
}
Filedownload.save(is, rr.getData().getMimeType(), rr.getData().getTitle() + ext);
...
Using an input stream on ZK 3.5.1/3.5.2
The only problem i have is with the name, it's downloaded as: 'This+file.txt', a not as i would like: 'This file.txt'
Hope that helps
Hi,
@dastultz: The bug seems to be fixed in ZK 3.6.1-FL version. You can download them here - https://sourceforge.net/project/showfiles.php?group_id=152762&package_id=218698
@msrednsi: The downloaded file name seems not to be with a space.
/Jumper
Asked: 2009-03-29 17:43:14 +0800
Seen: 301 times
Last updated: Mar 30 '09