Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi committed Apr 9, 2024
1 parent b2ff09b commit 09d3b88
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions http/filestream/filestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ type FileInfo struct {
Path string
}

func WriteFilesToStream(multipartWriter *multipart.Writer, filesList []*FileInfo) (err error) {
// Close finishes the multipart message and writes the trailing
// boundary end line to the output.
defer ioutils.Close(multipartWriter, &err)
func WriteFilesToStream(multipartWriter *multipart.Writer, filesList []*FileInfo) error {
for _, file := range filesList {
if err = writeFile(multipartWriter, file); err != nil {
if err := writeFile(multipartWriter, file); err != nil {
return writeErrPart(multipartWriter, file, err)
}
}

return nil
// Close finishes the multipart message and writes the trailing
// boundary end line to the output.
// We don't use defer for this because the multipart.Writer's Close() method writes regardless of whether there was an error or if writing hadn't started at all
return multipartWriter.Close()
}

func writeFile(multipartWriter *multipart.Writer, file *FileInfo) (err error) {
Expand Down

0 comments on commit 09d3b88

Please sign in to comment.