Skip to content

Commit

Permalink
reset file reader when retry a multipart file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Jun 16, 2023
1 parent a50ca79 commit 767a6b9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ func writeMultipartFormFile(w *multipart.Writer, file *FileUpload, r *Request) e
return err
}
defer content.Close()
if r.RetryAttempt > 0 { // reset file reader when retry a multipart file upload
if rs, ok := content.(io.ReadSeeker); ok {
_, err = rs.Seek(0, io.SeekStart)
if err != nil {
return err
}
}
}
// Auto detect actual multipart content type
cbuf := make([]byte, 512)
seeEOF := false
Expand Down

0 comments on commit 767a6b9

Please sign in to comment.