Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxFileCount improperly checked #25

Open
WoozyG opened this issue Jan 19, 2017 · 3 comments
Open

MaxFileCount improperly checked #25

WoozyG opened this issue Jan 19, 2017 · 3 comments

Comments

@WoozyG
Copy link
Contributor

WoozyG commented Jan 19, 2017

VMultiUpload.submit() contains this line:

} else if (maxFileCount != null && filedetails.size() >= maxFileCount) {

This means if you set maxFileCount = 1 and 1 file is selected, it thinks that's too many files!

Should be strictly greater than, not greater or equal.

And yes, it's a multi-file upload and I'm limiting it to one file for a special case. I needed drag and drop.

WoozyG added a commit to WoozyG/easyuploads that referenced this issue Mar 2, 2017
fix bounds check for maxFileCount to allow for uploading 1 file
mstahv added a commit that referenced this issue Mar 17, 2017
@mstahv
Copy link
Collaborator

mstahv commented Mar 17, 2017

I added this test, but couldn't reproduce the issue:

https://github.com/parttio/easyuploads/blob/01cc00ed8c0283291324664b5f60fa683f302bed/src/test/java/org/vaadin/easyuploads/demoandtestapp/MultiUploadWithMaxOneFiles.java

If you can reproduce the issue with that code, let me know which browser and OS you are using, it is then probably an environment issue.

@WoozyG
Copy link
Contributor Author

WoozyG commented Mar 17, 2017

Hmm. I see the problem when I try to select or drop a second file, after handling the first file. I thought I reset things on the server, maybe I missed a step, or the client doesn't clear its file list after the server handles an upload?

My use case is the same component is used multiple times for uploading single files and handling them immediately. Might I have to destroy the component and replace it logically in the UI after every upload?

The reason for the single file limit is that it is always replacing the contents of a specific data object, not adding new ones, so only one file makes sense.

@mstahv
Copy link
Collaborator

mstahv commented Mar 20, 2017

Ok, so I guess we'd need some sort of "reset()" or "clear()" method for MultiFileUpload? That could be handy. Will you create a new enhancement issue for that?

Replacing the old component with a new one is probably a decent workaround until the reset method is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants