.Net Core Minio 客户端在 Ubuntu 16.04 上收到错误

.Net Core Minio Client receives error on Ubuntu 16.04

目前我正在使用 minio 客户端 .net core 将文件存储到 Digital Ocean Spaces。我已经在 MacOS 上测试了当前的实现,代码将文件上传到 s3。部署到 Ubuntu 16.04 后,我收到以下错误。任何帮助,将不胜感激。谢谢

堆栈跟踪

Minio Exception: : Minio.Exceptions.MinioException: MinIO API responded with message=
   at Minio.MinioClient.ParseError(IRestResponse response) in /q/.q/sources/minio-dotnet/Minio/MinioClient.cs:line 381
   at Minio.MinioClient.HandleIfErrorResponse(IRestResponse response, IEnumerable`1 handlers, DateTime startTime) in /q/.q/sources/minio-dotnet/Minio/MinioClient.cs:line 526
   at Minio.MinioClient.<ExecuteTaskAsync>d__84.MoveNext() in /q/.q/sources/minio-dotnet/Minio/MinioClient.cs:line 370
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Minio.MinioClient.<PutObjectAsync>d__20.MoveNext() in /q/.q/sources/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 489
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Minio.MinioClient.<PutObjectAsync>d__15.MoveNext() in /q/.q/sources/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 254
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Minio.MinioClient.<PutObjectAsync>d__14.MoveNext() in /q/.q/sources/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 200
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CMTZ.Services.S3Service.<uploadS3File>d__8.MoveNext() in /home/rshaw/certified-mixtapes-core/CMTZ.Services/S3Service.cs:line 95

追踪

- - - - - - - - - - BEGIN REQUEST - - - - - - - - - -

PUT https://nyc3.digitaloceanspaces.com/cmtz/UploadedFiles/Mixtapes/test-upload-mixtape-20/cover.jpg HTTP/1.1
Host: nyc3.digitaloceanspaces.com:443
image/jpeg: System.Byte[]
x-amz-acl: public-read
Content-Type: image/jpeg
Content-MD5: ****************
x-amz-content-sha256: UNSIGNED-PAYLOAD
x-amz-date: 20191104T030850Z
Authorization: AWS4-HMAC-SHA256 Credential=*****************/20191104/us-east-1/s3/aws4_request, SignedHeaders=content-md5;host;x-amz-acl;x-amz-content-sha256;x-amz-date, Signature=fa6945a220238a7f877fb62d898d5596d9199860455499cec6bedccfb9cae0ed


- - - - - - - - - - END REQUEST - - - - - - - - - -

- - - - - - - - - - BEGIN RESPONSE - - - - - - - - - -

HTTP/1.1 403 Forbidden
x-amz-request-id: tx00000000000000ae68c6c-005dbf9642-334525e-nyc3a
Accept-Ranges: bytes
Date: Mon, 04 Nov 2019 03:08:50 GMT
Strict-Transport-Security: max-age=15552000; includeSubDomains; preload
Content-Length: 192
Content-Type: application/xml


<?xml version="1.0" encoding="UTF-8"?><Error><Code>SignatureDoesNotMatch</Code><RequestId>tx00000000000000ae68c6c-005dbf9642-334525e-nyc3a</RequestId><HostId>334525e-nyc3a-nyc</HostId></Error>

- - - - - - - - - - END RESPONSE - - - - - - - - - -

实施

        public async void uploadS3File(String filePath, String key, string type)
        {
            Console.WriteLine($"Uploading Object: {filePath}");
            try
            {
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("x-amz-acl", "public-read");
                var minio = new MinioClient(Configuration.S3_HOST_ENDPOINT,
                    Configuration.S3_ACCESS_KEY, Configuration.S3_SECRET_KEY).WithSSL();
                minio.SetTraceOn();

                await minio.PutObjectAsync(Configuration.Bucket,
                                         key, filePath, contentType: type, metaData: map);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Minio Exception: {ex}");

            }
        }

通过将我的项目目标升级到 .net core 2.1,我能够在 Linux 上解决上述问题。 RestSharp 似乎有问题。该库正在删除 asp.net 核心 2.0 中的端口号。确保在 minio-client-dotnet 中使用 RestSharp 版本依赖项。升级到最新版本,上传文件名中带括号和句点的对象时,再次出现签名相关错误