feat(webdav): support http chunked request (close #5161 in #5162)

But we do not recommend not adding the content-length header when putting files
pull/5184/head
fregie 2023-09-05 13:03:29 +08:00 committed by GitHub
parent 3c66db9845
commit b604e21c69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -26,6 +26,16 @@ type FileStream struct {
peekBuff *bytes.Reader 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 { func (f *FileStream) GetMimetype() string {
return f.Mimetype return f.Mimetype
} }

View File

@ -126,7 +126,7 @@ func CreateTempFile(r io.Reader, size int64) (*os.File, error) {
_ = os.Remove(f.Name()) _ = os.Remove(f.Name())
return nil, errs.NewErr(err, "CreateTempFile failed") return nil, errs.NewErr(err, "CreateTempFile failed")
} }
if size != 0 && readBytes != size { if size > 0 && readBytes != size {
_ = os.Remove(f.Name()) _ = os.Remove(f.Name())
return nil, errs.NewErr(err, "CreateTempFile failed, incoming stream actual size= %d, expect = %d ", readBytes, size) return nil, errs.NewErr(err, "CreateTempFile failed, incoming stream actual size= %d, expect = %d ", readBytes, size)
} }