public DownloadAsync ( |
||
request | /// Contains all the parameters required to download an Amazon S3 object. /// | |
cancellationToken | /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// | |
Résultat | Task |
public async Task DownloadFile(IStorageFile storageFile, string bucket, string key, AWSCredentials credentials, CancellationToken cancellationToken) { var s3Client = new AmazonS3Client(credentials, RegionEndpoint.USEast1); using (var transferUtility = new TransferUtility(s3Client)) { var downloadRequest = new TransferUtilityDownloadRequest { BucketName = bucket, Key = key, StorageFile = storageFile }; downloadRequest.WriteObjectProgressEvent += OnWriteObjectProgressEvent; await transferUtility.DownloadAsync(downloadRequest, cancellationToken); } }
public async Task DownloadFile(IStorageFile storageFile, string key, CancellationToken cancellationToken) { BasicAWSCredentials credentials = new BasicAWSCredentials("AKIAJTADDHY7T7GZXX5Q", "n4xV5B25mt7e6br84H2G9SXBx8eDYTQJgCxoaF49"); var s3Client = new AmazonS3Client(credentials, RegionEndpoint.USEast1); //files = await Windows.Storage.DownloadsFolder.CreateFileAsync(); using (var transferUtility = new TransferUtility(s3Client)) { var downloadRequest = new TransferUtilityDownloadRequest { BucketName = ExistingBucketName, Key = key, StorageFile = storageFile }; downloadRequest.WriteObjectProgressEvent += OnWriteObjectProgressEvent; await transferUtility.DownloadAsync(downloadRequest, cancellationToken); } }