0

How to do streaming download from database

asked 2009-03-29 17:43:14 +0800

dastultz gravatar image dastultz
797 9

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

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2009-03-30 01:35:20 +0800

YamilBracho gravatar image YamilBracho
1722 2

I think this is a bug.
Report to http://sourceforge.net/tracker/?group_id=152762&atid=785191

link publish delete flag offensive edit

answered 2009-03-30 06:22:40 +0800

msrednsi gravatar image msrednsi
106 2

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

link publish delete flag offensive edit

answered 2009-03-30 06:43:09 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

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

link publish delete flag offensive edit

answered 2009-03-30 08:27:43 +0800

msrednsi gravatar image msrednsi
106 2

Jumper: For example, when downloading this report: "Customer's sales conditions.PDF" y get the file name: "Customer%27s+sales+conditions.PDF", using safari/ff/opera on Mac OS X 10.4.11

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-03-29 17:43:14 +0800

Seen: 301 times

Last updated: Mar 30 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More