【问题标题】:How to use amazon S3 in c#?如何在 C# 中使用亚马逊 S3?
【发布时间】:2019-10-02 13:35:16
【问题描述】:

我想用 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.

【问题讨论】:

    标签: c# amazon-s3


    【解决方案1】:

    请参阅official sample。检查凭据和密钥名称,因为它们的无效值可能会导致您看到的错误。

    【讨论】:

      【解决方案2】:

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

      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
      

      【讨论】:

        【解决方案3】:

        错误推断它是一个凭据问题,或者您可能没有指定 KeyName - 通常 keyname 只是文件名:

        string keyName="file.txt";
        string bucketName="mybucket";
        string directoryFile="C:\\MyDownloadFile";
        
        TransferUtility utility=new TransferUtility(client);
        fileTransferUtility.Download(directoryPath,bucketName,keyName); 
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2010-10-20
          • 2012-05-01
          • 2018-02-10
          • 2013-05-12
          • 2017-07-18
          • 1970-01-01
          相关资源
          最近更新 更多