Skip to content

Commit

Permalink
feat(webdav): support http chunked request (close #5161 in #5162)
Browse files Browse the repository at this point in the history
But we do not recommend not adding the content-length header when putting files
  • Loading branch information
fregie authored Sep 5, 2023
1 parent 3c66db9 commit b604e21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions internal/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ type FileStream struct {
peekBuff *bytes.Reader
}

func (f *FileStream) GetSize() int64 {
if f.tmpFile != nil {
info, err := f.tmpFile.Stat()
if err == nil {
return info.Size()
}
}
return f.Obj.GetSize()
}

func (f *FileStream) GetMimetype() string {
return f.Mimetype
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func CreateTempFile(r io.Reader, size int64) (*os.File, error) {
_ = os.Remove(f.Name())
return nil, errs.NewErr(err, "CreateTempFile failed")
}
if size != 0 && readBytes != size {
if size > 0 && readBytes != size {
_ = os.Remove(f.Name())
return nil, errs.NewErr(err, "CreateTempFile failed, incoming stream actual size= %d, expect = %d ", readBytes, size)
}
Expand Down

0 comments on commit b604e21

Please sign in to comment.