Forum Libraries, Components, and Plugins

Run download method with AWS S3 in Xamarin Forms

FabricioBertaniFabricioBertani USMember ✭✭✭

Hi everyone, i'm testing the Amazon Web Services with S3 cloud and trying to make a simple download test from cloud, but i'm stuck with the code and i need a little push up into the right direction, i try to following this two guides from the AWS docs:

When i tryit on i only get asyncs methods and i have absolutely no idea how to implement it, here is some of my code:

public class downloadFile : ContentPage
    string filePath = "";
    string bucketName = "***";
    string key = "test.jpg";

    public downloadFile()
        CognitoAWSCredentials credentials = new CognitoAWSCredentials(

        var config = new TransferUtilityConfig();

        var s3Client = new AmazonS3Client(credentials, RegionEndpoint.USEast1);
        var transferUtility = new TransferUtility(s3Client, config);

        TransferUtilityDownloadRequest request = new TransferUtilityDownloadRequest();
        request.BucketName = bucketName;
        request.Key = key;

        transferUtility.DownloadAsync ??????? // Please help me here

Best Answer


  • ManoNagarajanManoNagarajan USMember ✭✭

    How to find downloaded file in iOS. Do you have any sample.?

  • kztnedakztneda Member ✭✭

    Hi, I'm actually in the same problem but when I try to download a file I get "System.ArgumentOutOfRangeException" so the app literally breaks out even when I use try-catch. Does any-one know what is happen?

    Here is my code:

     using (_clienteS3 = new AmazonS3Client("USER", "PASS", RegionEndpoint.USWest2))
                        var fileCopyName = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, Android.OS.Environment.DirectoryDownloads);
                        TransferUtilityDownloadRequest request = new TransferUtilityDownloadRequest()
                            BucketName = "BUKET",
                            Key = "FILE.png",
                            FilePath = fileCopyName
                        TransferUtility transferUtility = new TransferUtility(_clienteS3);
                        await transferUtility.DownloadAsync(request).ConfigureAwait(false); // here the app breaks-out and throws the exception before it closes (the app)
                    catch (Exception e) { } //doesn't catch de exception
  • FabricioBertaniFabricioBertani USMember ✭✭✭

    @kztneda did you try to wrap the using(...) with the try/catch instead of using it inside ?
    Also looks like you don't set your cognito credentials.

  • kztnedakztneda Member ✭✭

    are the cognito credentials needed even when the s3 client is logged in?
    yep, I tried it.

    I don't know what else can I do to get an object

Sign In or Register to comment.