I want to run some checks when flow.on('fileAdded') is fired, for example comparing the file size with a threshold.
In case the file is too big, I want to reject it and call flow.cancel().
However, the file is actually not in the flow.files list at that point. It is added directly afterwards, see flow.js:
if (this.fire('fileAdded', f, event)) {
files.push(f);
}
So calling cancel() doesn't work, the file is added to the list and stays there.
This behavior has already led to unexpected behavior several times in my project.
I work around it by running the file size check at a later point, but isn't there a better way to handle this? Am I missing something?
I want to run some checks when
flow.on('fileAdded')
is fired, for example comparing the file size with a threshold. In case the file is too big, I want to reject it and callflow.cancel()
. However, the file is actually not in theflow.files
list at that point. It is added directly afterwards, seeflow.js
:So calling
cancel()
doesn't work, the file is added to the list and stays there.This behavior has already led to unexpected behavior several times in my project.
I work around it by running the file size check at a later point, but isn't there a better way to handle this? Am I missing something?