Big file upload (suggestion of implementation... if possible)

asked 2011-07-29 09:37:56 +0800

shumy gravatar image shumy
244 1

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)

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2011-08-01 12:09:52 +0800

iantsai gravatar image iantsai
2755 1

updated 2011-08-01 12:17:07 +0800

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:

  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!

link publish delete flag offensive edit

answered 2011-08-02 08:45:47 +0800

shumy gravatar image shumy
244 1

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.

link publish delete flag offensive edit

answered 2011-08-03 16:46:32 +0800

iantsai gravatar image iantsai
2755 1

So the solution that I provide works in ZK3.6?

I didn't expect that, but that's great!

link publish delete flag offensive edit

answered 2011-08-04 05:19:05 +0800

shumy gravatar image shumy
244 1

updated 2011-08-04 05:20:20 +0800

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.

link publish delete flag offensive edit

answered 2012-03-15 14:03:06 +0800

crack2mann gravatar image crack2mann

@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.

link publish delete flag offensive edit

answered 2012-03-15 19:08:45 +0800

shumy gravatar image shumy
244 1

updated 2012-03-15 19:23:56 +0800

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!"

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




Asked: 2011-07-29 09:37:56 +0800

Seen: 390 times

Last updated: Mar 15 '12

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