I am kind of new to AWS s3 bucket concept. I am suppose to download files from folder "TODAY FILE1" in s3 bucket and use it. I know how to do it in command line using command prompt. I do not know how to implement in C#.
Suppose
Here's what I do it command prompt
C:\> aws s3 cp "s3://mys3bucket-output/TODAY FILE1" . --recursive
this is what I do it C# program and get error
string accessKey = "abc123";
string secretKey = "secret123";
string bucketName = "mys3bucket-output"
TransferUtility fileTransferUtility = new TransferUtility(new AmazonS3Client(accessKey, secretKey, Amazon.RegionEndpoint.USEast2));
BasicAWSCredentials basicCredentials = new BasicAWSCredentials(accessKey,secretKey);
AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey), Amazon.RegionEndpoint.USEast2);
ListObjectsRequest request = new ListObjectsRequest();
ListObjectsResponse response = s3Client.ListObjects(request.BucketName= bucketName, request.Prefix="TODAY FILE1/");
foreach (S3Object obj in response.S3Objects)
{
try
{
Console.WriteLine("{0}", obj.Key);
fileTransferUtility.Download(@"C:\Temp", bucketName, obj.Key);
}
catch (Exception Excep)
{
Console.WriteLine(Excep.Message, Excep.InnerException);
}
}
I get an exception Amazon.Runtime.AmazonServiceException: 'Access to the path 'C:\Temp' is denied
I do not know what to do Thanks MR