From 5323efe519c828b9b97dc52f13386e007e5972b5 Mon Sep 17 00:00:00 2001 From: roc Date: Mon, 20 Nov 2023 13:02:21 +0800 Subject: [PATCH] Fix retry in SetFileBytes (#300) --- request.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/request.go b/request.go index 2e0fceb..7a5942a 100644 --- a/request.go +++ b/request.go @@ -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