Skip to content

Commit

Permalink
Merge pull request #54 from leancloud/fix/upload-file
Browse files Browse the repository at this point in the history
(fix) Close resp body when uploading file.
  • Loading branch information
nicecui authored Oct 27, 2022
2 parents 7d89f2f + 885663d commit 8f78458
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor
.envrc
2 changes: 2 additions & 0 deletions leancloud/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8f78458

Please sign in to comment.