-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am using Zk dropupload to upload the file but I have some constraints to upload the file less than 2 gb. I want to restrict the user not to upload the file greater than 2 gb but not by using dropupload maxsize="5120". It should be done on onUpload event. Is there any other way to get the uploaded file size in less time.
otherwise you can count the written bytes and stop it after 2gb
final long MAX_SIZE = 2147483648L;
long currentSize = 0;
byte[] buffer = new byte[1024 * 8];
for (int count; (count = inputStream.read(buffer)) != -1;) {
currentSize += count;
if (currentSize >= MAX_SIZE) {
System.out.println("too big!");
break;
}
outputStream.write(buffer, 0, count);
}
Hello psingh,
Fastest solution i can think of is to create a temporary file and get the file size using the command:
file.length();
Reference: https://www.mkyong.com/java/how-to-create-temporary-file-in-java/
Best Regards,
Darksu
Asked: 2016-09-20 10:20:53 +0800
Seen: 32 times
Last updated: Sep 20 '16
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]