firefly
firefly copied to clipboard
Get a misleading error message when uploading file to data endpoint without setting a file name
If uploading a file to the /namespaces/{ns}/data endpoint, and the file name is "" or not set, the request will fail with a misleading error message:
{ "error": "FF10218: Error reading multi-part form input: EOF" }
https://github.com/hyperledger/firefly/blob/e9b7b74be7a0bd0719313b8dc35f265c84100d28/internal/apiserver/server.go#L130-L152
Heyy @lil131 , @awrichar , can I work on this issue?
Here's what I can perform
func uploadHandler(w http.ResponseWriter, r *http.Request) {
// Check if the file name is empty or not set
file, header, err := r.FormFile("file")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer file.Close()
if header.Filename == "" {
http.Error(w, "Error: File name is empty or not set", http.StatusBadRequest)
return
}
fmt.Fprintf(w, "File uploaded successfully!")
}