diff --git a/internal/stream/stream.go b/internal/stream/stream.go index 8bc27b3a4d3..a45735d035a 100644 --- a/internal/stream/stream.go +++ b/internal/stream/stream.go @@ -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 } diff --git a/pkg/utils/file.go b/pkg/utils/file.go index ada1d5e2a13..31803a95b2d 100644 --- a/pkg/utils/file.go +++ b/pkg/utils/file.go @@ -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) }