为了账号安全,请及时绑定邮箱和手机立即绑定

如何在c#中使用亚马逊S3?

如何在c#中使用亚马逊S3?

PHP
慕慕森 2024-01-20 16:08:09
我想使用 amazon s3 下载文件。我有存储桶名称、秘密和访问密钥。什么是区域端点以及如何设置它我可以使用我拥有的这些信息下载文件吗string accessKey="access key";string secretKey="secret key";string bucketName="my bucket name";string directoryFile="File directory";TransferUtility utility=new TransferUtility(client); //download.   --But this line error.Error is:The request we calculated does not match the signature you provided.Check your key and signing method.
查看完整描述

3 回答

?
慕盖茨4494581

TA贡献1850条经验 获得超11个赞

该错误推断其存在凭据问题,或者您可能没有指定密钥名称 - 通常密钥名称只是文件名:


string keyName="file.txt";

string bucketName="mybucket";

string directoryFile="C:\\MyDownloadFile";


TransferUtility utility=new TransferUtility(client);

fileTransferUtility.Download(directoryPath,bucketName,keyName); 


查看完整回答
反对 回复 2024-01-20
?
慕桂英4014372

TA贡献1871条经验 获得超13个赞

检查凭据和密钥名称,因为这些值无效可能会导致您看到错误。



查看完整回答
反对 回复 2024-01-20
?
芜湖不芜

TA贡献1796条经验 获得超7个赞

检查您的目录和文件名。桌面和服务器上的目录不同。


string accessKey="my access key";

string secretKey="my secret key";

string bucketName="my bucket name";

string directoryFile=@"C:\MyDownloadFile"; //Please check your directory access


TransferUtility fileTransferUtility =

    new TransferUtility(

        new AmazonS3Client("ACCESS-KEY-ID", "SECRET-ACCESS-KEY", Amazon.RegionEndpoint.CACentral1));


// Note the 'fileName' is the 'key' of the object in S3 (which is usually just the file name)

fileTransferUtility.Download(filePath, "my-bucket-name", fileName); // check file name as your keyName



查看完整回答
反对 回复 2024-01-20
  • 3 回答
  • 0 关注
  • 39 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信