Skip to content

Commit

Permalink
Fix retry in SetFileBytes (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Nov 20, 2023
1 parent bc2bf86 commit 5323efe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,14 @@ func (r *Request) SetFileReader(paramName, filename string, reader io.Reader) *R

// SetFileBytes set up a multipart form with given []byte to upload.
func (r *Request) SetFileBytes(paramName, filename string, content []byte) *Request {
return r.SetFileReader(paramName, filename, bytes.NewReader(content))
r.SetFileUpload(FileUpload{
ParamName: paramName,
FileName: filename,
GetFileContent: func() (io.ReadCloser, error) {
return io.NopCloser(bytes.NewReader(content)), nil
},
})
return r
}

// SetFiles set up a multipart form from a map to upload, which
Expand Down

0 comments on commit 5323efe

Please sign in to comment.