尝试将文件上传到数字海洋.NET 时没有 SuchBucket 错误

tin*_*ine 1 c# digital-ocean

我在将文件上传到 digitalocean 时遇到问题。

private static readonly AmazonS3Config s3ClientConfig = new AmazonS3Config
               {
                   ServiceURL = digOceanEndPoint
       };
private static async Task DO_UploadFileAsync()
        {
            //Test DigitalOcean Upload
            try
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

                IAmazonS3 s3Client = new AmazonS3Client(awsAccessKey, awsSecretKey, s3ClientConfig);
                
                var fileTransferUtility = new TransferUtility(s3Client);
                var fileTransferUtilityRequest = new TransferUtilityUploadRequest
                {
                    BucketName = "valentindb",
                    FilePath = "C:\\Temp\\HelpDesk.jpg",
                    StorageClass = S3StorageClass.StandardInfrequentAccess,
                    PartSize = 6291456, // 6 MB
                    Key = "HelpDesk.jpg",
                    CannedACL = S3CannedACL.PublicRead
                };
                await fileTransferUtility.UploadAsync(fileTransferUtilityRequest);

            }
            catch (AmazonS3Exception e)
            {
                errorMessage = e.Message;
                Console.WriteLine("AWS Error encountered on server. Message:'{0}' when writing an object", e.Message);
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
                Console.WriteLine("Unknown encountered on server. Message:'{0}' when writing an object", e.Message);
            }
        } 
Run Code Online (Sandbox Code Playgroud)

这是我尝试使用的代码。当我进入 UploadAsync 函数时,抛出异常,状态为:“发出请求时出错,错误代码为 NoSuchBucket,Http 状态代码为 NotFound。服务未返回进一步的错误信息。”

有谁知道出了什么问题,我应该检查什么?

tin*_*ine 5

我想到了。

BucketName =“valentindb”,应该是=>“valentindb.yourRegion.digitaloceanspaces.com”

我不明白为什么,但现在可以上传了。