[v1] Suggestion for QUploader: Reintroduce fixed field names for files in the uploaded form data
Before v1.0.0-beta QUploader uploaded files like:
Content-Disposition: form-data; name="file"; filename="test.jpg"
In v1.0.0-beta.2 it‘s now:
Content-Disposition: form-data; name="test.jpg"; filename="test.jpg"
Although this is not a problem is makes it harder to handle the file upload on the server side. You no longer know the field name and so it‘s not possible anymore to use a Spring resolver to get the file, e.g. with `@PostMapping(path = "/upload/image")
public void upload(@RequestParam("file") MultipartFile file) { … }`
The filename itself is sent anyway and is not needed in name (in my opinion).
Suggestion
Instead of
form.append(file.name, file)
which is what QUploader is doing now, it could be
form.append(this.formNameForFile(file), file)
with method
formNameForFile (file) {
return this.formName ? this.formName : file.name
}
and prop formName
or without a prop:
formNameForFile (file) {
return file.name
}
This would at least allow to override the behaviour in a derived own component easily.
Thanks for considering
Hi,
Thanks for pointing this out. Added field-name prop for this. Can be either Function or String. Check my commit above.
Will be available in beta.4.
Hi,
your are awesome ! Thanks a lot (for this and Quasar)
Martin