【发布时间】:2023-04-04 13:55:02
【问题描述】:
我遇到错误 -
我们计算的请求签名与您提供的签名不匹配。检查您的秘密访问密钥和签名方法。有关详细信息,请参阅 REST 身份验证和 SOAP 身份验证了解详细信息。'
远程服务器返回错误:(403) Forbidden。
我检查了我的密钥,里面没有空格。
我的钥匙看起来像 -
TestArea/Destination/SUP000011/ATM-1B4L2KQ0ZE0-0001/SoS_Update_2018_06_04_pram.pptx
代码 -
public static Stream GetObjectStream(string keyName)
{
GetObjectRequest request = new GetObjectRequest
{
BucketName = bucketName,
Key = keyName
};
using (AmazonS3Client StorageClient = GetClient())
//This line gives error (getting response)
using (GetObjectResponse response = StorageClient.GetObject(request))
using (Stream responseStream = response.ResponseStream)
{
return responseStream;
}
}
public static Amazon.S3.AmazonS3Client GetClient()
{
AmazonS3Config Config = new AmazonS3Config();
AmazonS3Client StorageClient;
Config.RegionEndpoint = null;
Config.ServiceURL = ConfigurationManager.NGDMSobjECSEndPoint;
Config.AllowAutoRedirect = true;
Config.ForcePathStyle = true;
StorageClient = new AmazonS3Client(ConfigurationManager.NGDMSobjECSUser, ConfigurationManager.NGDMSobjECSKey, Config);
return StorageClient;
}
【问题讨论】: