使用 C# 拒绝 AWS TransferUtility 下载访问

时间:2021-06-27 20:56:46

标签: amazon-s3 download

我正在尝试将文件从 S3 存储桶下载到 C# 应用程序中的本地驱动器。使用 ListObjects API 调用获取文件夹中的文件列表没有问题。但是,当我尝试执行下载 API 调用时,我对“C”驱动器上的本地文件夹的访问被拒绝。该文件夹存在并位于应用程序的执行目录下。该文件夹对每个人都具有完全访问权限。无论我将文件夹移到哪里,我都会遇到同样的错误。

//create client
var client = new AmazonS3Client(new BasicAWSCredentials(configHelper.S3AccessKey, configHelper.S3SecretKey), configHelper.S3Region);

//get directory of files in S3 bucket
ListObjectsRequest request = new ListObjectsRequest();
client.ListObjects(request.BucketName = configHelper.S3BucketName); //works fine

//download file. localFolder = c:\... obj.Key is a file name in the S3 bucket
var fileTransferUtility = new TransferUtility(client);
fileTransferUtility.Download(localFolder, configHelper.S3BucketName, obj.Key); //access error

0 个答案:

没有答案
相关问题