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

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


慕慕森
浏览 87回答 3
3回答

慕盖茨4494581

该错误推断其存在凭据问题,或者您可能没有指定密钥名称 - 通常密钥名称只是文件名:string keyName="file.txt";string bucketName="mybucket";string directoryFile="C:\\MyDownloadFile";TransferUtility utility=new TransferUtility(client);fileTransferUtility.Download(directoryPath,bucketName,keyName); 

慕桂英4014372

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

芜湖不芜

检查您的目录和文件名。桌面和服务器上的目录不同。string accessKey="my access key";string secretKey="my secret key";string bucketName="my bucket name";string directoryFile=@"C:\MyDownloadFile"; //Please check your directory accessTransferUtility 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
打开App,查看更多内容
随时随地看视频慕课网APP