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

Fix original file upload to use actual file name rather than uploadxxx.tmp #893

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public UploadedFile<T>[] getFile(String fieldName) {
*/
public String[] getFileNames(String fieldName) {
return uploadedFiles.getOrDefault(fieldName, Collections.emptyList()).stream()
.map(file -> getCanonicalName(file.getName()))
.map(file -> getCanonicalName(file.getOriginalName()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the same is on 6.xx, see here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found where this bug comes from, Commons FileItem.getName() returns:

Returns the original filename in the client's filesystem, as provided by the browser (or other client software)

and UploadedFile.getName() returns name of the uploaded file on the server side, so you are right.

.toArray(String[]::new);
}

Expand Down
Loading