From 8abde99c6d7b4d6af5a046f9812ea485fc225128 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 24 Nov 2022 16:48:56 +0800 Subject: Fix seek. --- docker/auto-backup/AutoBackup/TencentCloudCOS.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docker/auto-backup') diff --git a/docker/auto-backup/AutoBackup/TencentCloudCOS.cs b/docker/auto-backup/AutoBackup/TencentCloudCOS.cs index c3d245c..ae96db4 100644 --- a/docker/auto-backup/AutoBackup/TencentCloudCOS.cs +++ b/docker/auto-backup/AutoBackup/TencentCloudCOS.cs @@ -160,7 +160,7 @@ public static class TencentCloudCOSHelper public static async Task PutObject(Credentials credentials, string region, string bucket, string key, Stream dataStream) { - if (dataStream.CanSeek) + if (!dataStream.CanSeek) { throw new ArgumentException("Data stream must be seekable."); } @@ -170,6 +170,8 @@ public static class TencentCloudCOSHelper throw new ArgumentException("Data stream must be smaller than 5GB."); } + dataStream.Seek(0, SeekOrigin.Begin); + var host = GetHost(bucket, region); var encodedKey = WebUtility.UrlEncode(key); using var md5Handler = MD5.Create(); -- cgit v1.2.3