From 885663d84e68a94e995360511b4a79ab0b1485f2 Mon Sep 17 00:00:00 2001 From: Yiran Date: Wed, 26 Oct 2022 18:48:26 +0800 Subject: [PATCH] (fix) Close resp body when uploading file. --- .gitignore | 1 + leancloud/file.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 22d0d82..1168226 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor +.envrc \ No newline at end of file diff --git a/leancloud/file.go b/leancloud/file.go index 6ef7e22..8a64c91 100644 --- a/leancloud/file.go +++ b/leancloud/file.go @@ -176,6 +176,7 @@ func (file *File) uploadQiniu(token, uploadURL string, reader io.ReadSeeker) err if err != nil { return fmt.Errorf("unexpected error when upload file to Qiniu: %v", err) } + defer resp.Body.Close() err = <-done if err != nil { @@ -269,6 +270,7 @@ func (file *File) uploadCOS(token, uploadURL string, reader io.ReadSeeker) error if err != nil { return fmt.Errorf("unexpected error when upload file to COS: %v", err) } + defer resp.Body.Close() err = <-done if err != nil {