我正在尝试移植我们的C#控制台应用程序,该应用程序使用AWSPowerShell.NetCore进行部署到Powershell Core。
但是,当我尝试将对象写入S3时,它说指定的存储桶不存在。
Write-S3Object -BucketName "my.bucket.name" `
-Key "myfile.txt" `
-File "./myfile.txt" `
-CannedACLName public-read `
-AccessKey "my-aws-key" `
-SecretKey "my-aws-secret" `
-EndpointUrl "https://special-endpoint-url" `
-Region "us-west-2"
但是C#中相同的代码(至少据我所知)有效。
var config = new AmazonS3Config
{
ServiceURL = "https://special-endpoint-url",
RegionEndpoint = RegionEndpoint.USWest2
};
var creds = new BasicAWSCredentials("my-aws-key", "my-aws-secret");
using (var s3Client = new AmazonS3Client(creds , config))
{
var putObjectRequest = new PutObjectRequest()
{
BucketName = "my.bucket.name",
CannedACL = S3CannedACL.PublicRead,
FilePath = "./myfile.txt",
Key = "myfile.txt"
};
await s3Client.PutObjectAsync(putObjectRequest);
}
我已经仔细检查了存储桶的名称,但是在这里没有发现错误。