I am working on a project where I need to get Zip files from S3 Bucket. I was able to copy these files one at a time to my EC2 instance using
foreach (S3Object o in response.S3Objects)
{
GetObjectRequest requests = new GetObjectRequest();
requests.BucketName = "mybucket";
requests.Key = o.Key;
GetObjectResponse responses = client.GetObject(requests);
responses.WriteResponseStreamToFile(@"D:\myfile.zip");
Console.WriteLine("{0}\t{1}\t{2}", o.Key, o.Size, o.LastModified);
}
but I would like to unzip these files on the fly to a specific location instead of copy them locally. I tried the following but it did not work
using (ZipArchive archive = ZipFile.OpenRead(responses.ResponseStream.ToString())) //unzip file
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
archive.ExtractToDirectory(myPath);
}
}
}
Thanks