I use the following code to read text file from Amazon S3, and processing it line by line. This code works but the problem is it is slow.
GetObjectRequest getObjRequest = new GetObjectRequest()
.WithBucketName(amazonSettings.BucketName)
.WithKey(_fileKey);
using (AmazonS3 client = AWSClientFactory.CreateAmazonS3Client(
amazonSettings.AccessKey,
amazonSettings.SecretAccessKey))
using (GetObjectResponse getObjRespone = client.GetObject(getObjRequest))
using (Stream amazonStream = getObjRespone.ResponseStream)
{
StreamReader amazonStreamReader = new StreamReader(amazonStream);
tempGsContact = new GSContact();
while ((_fileLine = amazonStreamReader.ReadLine()) != null)
{
if (_fileLine.Equals("END:VCARD"))
{
// Make process 1
}
else if (!_fileLine.Equals(string.Empty))
{
//Make process 2
}
}
}
The question is: can I get more sufficient way to reduce the time cost?