amazon-archives / aws-sdk-xamarin

AWS Mobile SDK for Xamarin (Beta)
Apache License 2.0
45 stars 18 forks source link

How to download file in Amazon S3 with download progress in Xamarin? #44

Closed sridharsaminathan closed 7 years ago

sridharsaminathan commented 7 years ago

Hi,

I need to download a file in Amazon S3 in Xamarin android and Xamarin iOS. please help

tawalke commented 7 years ago

Hi @sridharsaminathan this version the SDK has been deprecated and rolled into the .NET SDK. Check out these resources: GitHub: https://github.com/aws/aws-sdk-net Installation: https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-install-assemblies.html Official Forums: http://forums.aws.amazon.com/forum.jspa?forumID=61 Documentation: https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/

Thanks, TEW

sridharsaminathan commented 7 years ago

Hi,

Thanks @tawalke. i have added AWSSDK.S3 from nuget packages

I have added the following code for downloading file Amazon S3. For S3Client i have used identity pool id with region. i am not getting response here var response = await S3Client.GetObjectAsync(request) .

Please find the code and help me to fix.

var S3Client = S3Utils.S3Client; bool responseBody = false; var request = new GetObjectRequest { BucketName = Constants.AWS.BUCKET_NAME.ToLowerInvariant(), Key = string.Format("{0}/{1}", Constants.AWS.FOLDER_NAME.ToLowerInvariant(), filename) }; try { using (var response = await S3Client.GetObjectAsync(request)) { string avatarFilepath = System.IO.Path.Combine(App.PersonalFolderPath, filename); await response.WriteResponseStreamToFileAsync(avatarFilepath, true); responseBody = true; } } catch (AmazonS3Exception s3Exception) { responseBody = false; } return responseBody;

Thanks, Sridhar

sridharsaminathan commented 7 years ago

i have got network issue it is resolved now