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

While using mutlipart form-data I am not able to set fieldName diff from fileName #63

Open
fsduser opened this issue Jul 25, 2022 · 1 comment

Comments

@fsduser
Copy link

fsduser commented Jul 25, 2022

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)).

@trackcan
Copy link

is there any solution? thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants