Skip to content

File added to "files" after fileAdded event fires #318

Open
@abulhol

Description

@abulhol

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions