Skip to content

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

@fsduser

Description

@fsduser

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions