Revision history [back]

click to hide/show revision 1
initial version

answered 2013-10-25 09:30:20 +0800

cor3000 gravatar image cor3000

ZK Team

Hi Frank,

I just double-checked with a very simple example (using ZK 6.5.4) and ZK does exactly what you describe out of the box.

my streaming-upload.zul:

<zk>
    <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('zk.forum.upload.StreamingUploadViewModel')" >
        <button id="upload" label="upload" upload="true" onUpload="@command('upload', media=event.media)" />
    </div>
</zk>

my View Model

package zk.forum.upload;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.util.media.Media;

public class StreamingUploadViewModel {
    @Command("upload") 
    public void onUpload(@BindingParam("media") Media media) {
        System.out.println(media.getStreamData());
    }
}

When you drag a large file over the button, it will start the upload, showing a progress bar giving you the chance to cancel the upload. Observing the memory, I could not notice any significant increase. And in the command handler method in the end you'll see that the stream is actually a FileInputStream. It is pointing to a temporary file in your user's temp folder.

If the behaviour is not the same in your case, please give me details about which exact ZK version you are using or an example to reproduce the memory increase leading to the exception.

Regards,

Robert

Hi Frank,

I just double-checked with a very simple example (using ZK 6.5.4) and ZK does exactly what you describe out of the box.

my streaming-upload.zul:

<zk>
    <div apply="org.zkoss.bind.BindComposer"  viewModel="@id('vm') @init('zk.forum.upload.StreamingUploadViewModel')" >
        <button id="upload" label="upload" upload="true" upload="true"
            onUpload="@command('upload', media=event.media)" />
    </div>
</zk>

my View Model

package zk.forum.upload;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.util.media.Media;

public class StreamingUploadViewModel {
    @Command("upload") 
    public void onUpload(@BindingParam("media") Media media) {
        System.out.println(media.getStreamData());
    }
}

When you drag a large file over the button, it will start the upload, showing a progress bar giving you the chance to cancel the upload. Observing the memory, I could not notice any significant increase. And in the command handler method in the end you'll see that the stream is actually a FileInputStream. It is pointing to a temporary file in your user's temp folder.

If the behaviour is not the same in your case, please give me details about which exact ZK version you are using or an example to reproduce the memory increase leading to the exception.

Regards,

Robert

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