File size of File before it's been uploaded

Is it possible to find out the file size of a file before it’s uploaded using the Vaadin Upload file component? The file types will vary significantly, any suggestions or insight would be helpful,

Thanks!

Hi,

The Upload.StartedEvent has a contentLength property, which it gets from the uploading browser. You can handle it in an Upload.StartedListener and interrupt the upload with interruptUpload().

It’s not possible to check a maximum length before the download begins. HTML actually
supports a MAXLENGTH attribute
, but it’s not used in Vaadin.

In any case, the content length is not mandatory and some browsers might not send it or a malicious user agent could fabricate it, so it should not be relied upon. You can also follow the actually uploaded data amount in a ProgressListener and terminate the upload there if it gets too big.

Excellent thank you for the response!