req icon indicating copy to clipboard operation
req copied to clipboard

Multipart form upload use huge amount of memory

Open n0v3xx opened this issue 1 year ago • 3 comments

Hi, i think there is a bug or something in your implementation, because if i want to upload a file here against this API: https://rapidgator.net/article/api/file#upload

v3 - bad memory usage way: I tried all upload ways, SetFileReader, SetFiles and so on

ursp2 := &UploadResponse{}
resp, err := r.Client.Client.R().
	SetHeader("User-Agent", Useragent).
	SetFileReader("file", fileName, rr).
	//SetFiles(map[string]string{
	//	"file": filePath,
	//}).
	SetSuccessResult(ursp2).
	SetErrorResult(&errMsg).
	Post(ursp.Response.Upload.URL)
if err != nil {
	mursp.Error = err
	r.Logger.ErrorLogger.Println(err.Error())
	fmt.Println(err)
	//c <- mursp
	return
}

The upload process load the hole file in memory and that use tons of RAM. I dont know why but i implement a plain multipart file upload like this here, that works fine, without this memory bug.

Could you try to improve your multipart form request?

Your old v0.3.2 works. No extrem RAM usage

n0v3xx avatar Apr 16 '23 12:04 n0v3xx