diff --git a/drivers/189pc/utils.go b/drivers/189pc/utils.go index 47a09c2178a..03144a525e9 100644 --- a/drivers/189pc/utils.go +++ b/drivers/189pc/utils.go @@ -508,7 +508,6 @@ func (y *Yun189PC) FastUpload(ctx context.Context, dstDir model.Obj, file model. _ = tempFile.Close() _ = os.Remove(tempFile.Name()) }() - file.SetReadCloser(tempFile) const DEFAULT int64 = 10485760 count := int(math.Ceil(float64(file.GetSize()) / float64(DEFAULT))) @@ -526,7 +525,7 @@ func (y *Yun189PC) FastUpload(ctx context.Context, dstDir model.Obj, file model. } silceMd5.Reset() - if _, err := io.CopyN(io.MultiWriter(fileMd5, silceMd5), file, DEFAULT); err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { + if _, err := io.CopyN(io.MultiWriter(fileMd5, silceMd5), tempFile, DEFAULT); err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { return err } md5Byte := silceMd5.Sum(nil) @@ -596,7 +595,7 @@ func (y *Yun189PC) FastUpload(ctx context.Context, dstDir model.Obj, file model. SetContext(ctx). SetQueryParams(clientSuffix()). SetHeaders(ParseHttpHeader(uploadData.RequestHeader)). - SetBody(io.LimitReader(file, DEFAULT)). + SetBody(io.LimitReader(tempFile, DEFAULT)). Put(uploadData.RequestURL) if err != nil { return err diff --git a/drivers/baidu_photo/driver.go b/drivers/baidu_photo/driver.go index ef2640842c2..f0f1d35daf2 100644 --- a/drivers/baidu_photo/driver.go +++ b/drivers/baidu_photo/driver.go @@ -177,7 +177,6 @@ func (d *BaiduPhoto) Put(ctx context.Context, dstDir model.Obj, stream model.Fil _ = tempFile.Close() _ = os.Remove(tempFile.Name()) }() - stream.SetReadCloser(tempFile) // 计算需要的数据 const DEFAULT = 1 << 22 @@ -195,7 +194,7 @@ func (d *BaiduPhoto) Put(ctx context.Context, dstDir model.Obj, stream model.Fil return ctx.Err() default: } - _, err := io.CopyN(io.MultiWriter(fileMd5, sliceMd5, slicemd52Write), stream, DEFAULT) + _, err := io.CopyN(io.MultiWriter(fileMd5, sliceMd5, slicemd52Write), tempFile, DEFAULT) if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { return err }