While using mutlipart form-data I am not able to set fieldName diff from fileName
fsduser opened this issue · 1 comments
I am creating formdata like below : Server requires form-data as : name=file ; filename=
The value of name is expected to "file" on sever and filename is the actual filename
Using the current mutipart I can only generate something like :
1> Content-Disposition;form-data; name=file ; filename=file
2> Content-Disposition;form-data; name=a.txt ; filename=a.txt
Cannot get something like :
3>Content-Disposition;form-data; name=file ; filename=a.txt
------WebKitFormBoundaryePkpFF7tjBAqx29L
Content-Disposition: form-data; name="file"; filename="a.txt"
Content-Type: application/octet**
... contents of file goes here ...
------WebKitFormBoundaryePkpFF7tjBAqx29L--
Here is the snippet I use and then pass it to gentelman's client.Use(multipart.Data(dt))
fields := map[string]common.Values{"attachment": {"SomeValue"}}
dt := common.FormData{
Data: fields,
Files: []common.FormFile{{Name: , Reader: r}},
}
It seems that when I pass "Name" in Formfile the fieldname also switches to "Name" .
It seems in the file :plugins/multipart/multipart.go (in function writeFile this change happens before passing these values to multipartWriter.CreateFormFile(fileName, file.Name)).
is there any solution? thx!