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

Optional Upload with malformed file multipart part #803

Closed
DrorBuhnik opened this issue Jun 1, 2017 · 2 comments · Fixed by #823
Closed

Optional Upload with malformed file multipart part #803

DrorBuhnik opened this issue Jun 1, 2017 · 2 comments · Fixed by #823
Milestone

Comments

@DrorBuhnik
Copy link
Contributor

When we have this endpoint:

@POST
public Result create(Optional<Upload> file, String other) {...}

And the client upload a multipart with 'file' part where the 'filename' doesn't exists we get weird result, file.isPresent() return true but he is a 'Object' type instead of 'Upload'
Currently we manually check it:

if (file.isPresent()) {
    if (!(file.get() instanceof Upload)) {
        throw new Exceptions.BadRequest("Upload 'file' is missing (did you put 'filename'?)");
    }
}
@DrorBuhnik DrorBuhnik changed the title Optional Upload with melform file multipart part Optional Upload with malformed file multipart part Jun 1, 2017
@jknack
Copy link
Member

jknack commented Jun 1, 2017

Will have to look, didn't know the filename attribute was optional

@DrorBuhnik
Copy link
Contributor Author

I'm not sure it is optional
I'm completely fine if such malformed part will result in Bad Request 400

@jknack jknack modified the milestones: 1.1.3, 1.2.0 Jun 18, 2017
jknack added a commit that referenced this issue Jun 23, 2017
Optional Upload with malformed file multipart part fix #803
jknack added a commit that referenced this issue Jun 23, 2017
Optional Upload with malformed file multipart part fix #803
jknack added a commit that referenced this issue Jun 29, 2017
Optional Upload with malformed file multipart part fix #803
jknack added a commit that referenced this issue Jul 3, 2017
Optional Upload with malformed file multipart part fix #803
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants