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

'file' is THE filedname sometime #225

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gorequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ type File struct {
// End()
//
// The second optional argument (third argument overall) is the fieldname in the multipart/form-data request. It defaults to fileNUMBER (eg. file1), where number is ascending and starts counting at 1.
// So if you send multiple files, the fieldnames will be file1, file2, ... unless it is overwritten. If fieldname is set to "file" it will be automatically set to fileNUMBER, where number is the greatest exsiting number+1.
// So if you send multiple files, the fieldnames will be file1, file2, ... unless it is overwritten. If fieldname is set to "" it will be automatically set to fileNUMBER, where number is the greatest exsiting number+1.
//
// b, _ := ioutil.ReadFile("./example_file.ext")
// gorequest.New().
Expand All @@ -897,7 +897,7 @@ func (s *SuperAgent) SendFile(file interface{}, args ...string) *SuperAgent {
if len(args) >= 2 && len(args[1]) > 0 {
fieldname = strings.TrimSpace(args[1])
}
if fieldname == "file" || fieldname == "" {
if fieldname == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May add a new args skip_file_number for backward compatibility

fieldname = "file" + strconv.Itoa(len(s.FileData)+1)
}

Expand Down