-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'am using Fileupload for big file uploads > 3GiB.
I have notice that the onUpload event is fired after the upload, and then I Media.getStreamData() and copy streams.
For this to work (since we ave no control on the upload process) a tmp file must be created, and when this is done the upload status is closed but... the process is not finished, we still need to copy streams! For big files this copy process can still run for several minutes and the user is misinformed of the upload status.
Is there any way to provide an OutputStream to the Fileupload, something similar to: Fileupload.setCopyTo(Outputstream os) that fires onUpload and use the upload status to report progress?
This will avoid the 2 problems mentioned (tmp file, wrong status report)
I think giving a static method like the setCopyTo(out) to class FileUpload is not a good idea.
Because, that sounds like you want to pipe every input Stream into that OutputStream and the data could be mixed if two upload processes were triggered concurrently. So, an OutputStream Provider could be a better idea.
But, the real question is, is this necessary?
Think about this scenario:
After uploading, the onUpload will be triggered, and you got the Media object to do what you want.
Then, because we know the file could be very huge, so it's better to notify client with a "processing" stuff before we continue the real IO process.
So, we should do things bellow while onUpload:
Clients.showBusy(); Events.echoEvent(new Event("onFileProcess", target, media));
Now, the only thing you need to think about is, where you can find a proper target to register an "onFileProcess" event listener ?
I think the button you used to handle fileupload is a good target.
I don't test the code that I wrote, but the concept is clear, so please take a try.
Also please give me a response no matter you success or not, thanks!
Yes sorry for the nomenclature, I was not referring to static methods.
I'm using ZK 3.6. A little different, but works fine.
Anyway, the "copyTo" solution will give a better feedback and will also remove the tmp files.
Yes, in a different way. ZK 3.6 doesn't have Events.echoEvent(String, Component, Object) only Events.echoEvent(String, Component, String).
I use:
Clients.showBusy("Saving files on signal storage...", true); Events.echoEvent("onFileProcess", self, null);
Where the self component is the window for this controller. "onFileProcess" handler is registered in "doAfterCompose".
The "Media[] mediaArray" is a controller field.
@Shumy can you help me with how to do a heavy file upload...i can't even upload 3MB file....it always returns "contentId is required". It works well until its deployed online. I'm in a fix and time is far spent on the project.
Can't help you. I don't know what is that content id. Seems like a production environment problem.
Maybe this helps:
Upload-Error "contentId is required!"
Asked: 2011-07-29 09:37:56 +0800
Seen: 390 times
Last updated: Mar 15 '12