public Task DownloadToAsync(IStorageFile storageFile, CancellationToken cancellationToken = default(CancellationToken)) { var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest(); request.BucketName = this.linker.s3.bucket; request.Key = this.linker.s3.key; request.StorageFile = storageFile; return GetTransferUtility().DownloadAsync(request, cancellationToken); }
/// <summary> /// Downloads the file from the S3Link's specified bucket and key then saves it in the given path. /// Creates directories and the file if they do not already exist. /// </summary> /// <param name="downloadPath">Path to save the file.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>An asynchronous task of the request</returns> public Task DownloadToAsync(string downloadPath, CancellationToken cancellationToken = default(CancellationToken)) { var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest(); request.BucketName = this.linker.s3.bucket; request.Key = this.linker.s3.key; request.FilePath = downloadPath; return GetTransferUtility().DownloadAsync(request, cancellationToken); }
/// <summary> /// Downloads the file from the S3Link's specified bucket and key then saves it in the given path. /// Creates directories and the file if they do not already exist. /// </summary> /// <param name="downloadPath">Path to save the file.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>An asynchronous task of the request</returns> public Task DownloadToAsync(string downloadPath, CancellationToken cancellationToken = default(CancellationToken)) { var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest(); request.BucketName = this.linker.s3.bucket; request.Key = this.linker.s3.key; request.FilePath = downloadPath; return(GetTransferUtility().DownloadAsync(request, cancellationToken)); }
public Task DownloadToAsync(IStorageFile storageFile, CancellationToken cancellationToken = default(CancellationToken)) { var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest(); request.BucketName = this.linker.s3.bucket; request.Key = this.linker.s3.key; request.StorageFile = storageFile; return(GetTransferUtility().DownloadAsync(request, cancellationToken)); }
void ICoreAmazonS3.DownloadToFilePath(string bucketName, string objectKey, string filepath, IDictionary <string, object> additionalProperties) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); transfer.Download(request); }
IAsyncResult ICoreAmazonS3.BeginDownloadToFilePath(string bucketName, string objectKey, string filepath, IDictionary <string, object> additionalProperties, AsyncCallback callback, object state) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(transfer.BeginDownload(request, callback, state)); }
Task ICoreAmazonS3.DownloadToFilePathAsync(string bucketName, string objectKey, string filepath, IDictionary <string, object> additionalProperties, CancellationToken cancellationToken) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); return(transfer.DownloadAsync(request, cancellationToken)); }
public void SimpleUpload() { RunAsSync(async() => { var client = Client; using (var tu = new Amazon.S3.Transfer.TransferUtility(client)) { await tu.UploadAsync(fullPath, bucketName); var response = await client.GetObjectMetadataAsync(new GetObjectMetadataRequest { BucketName = bucketName, Key = testFile }); Assert.IsTrue(response.ETag.Length > 0); var downloadPath = fullPath + ".download"; var downloadRequest = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = testFile, FilePath = downloadPath }; var fileExists = await this.BaseFolder.CheckExistsAsync(downloadPath); Assert.IsTrue(fileExists == ExistenceCheckResult.NotFound); await tu.DownloadAsync(downloadRequest); await TestDownloadedFile(downloadPath); // empty out file, except for 1 byte var file = await this.BaseFolder.GetFileAsync(downloadPath); await file.WriteAllTextAsync(testContent.Substring(0, 1)); await tu.DownloadAsync(downloadRequest); await TestDownloadedFile(downloadPath); } }); }
private async Task TestDownloadedFile(string fullPath, Amazon.S3.Transfer.TransferUtility tu, string key = null) { if (key == null) { key = testFile; } var downloadPath = fullPath + ".download"; var downloadRequest = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = key, FilePath = downloadPath }; var fileExists = await this.BaseFolder.CheckExistsAsync(downloadPath); if (fileExists == ExistenceCheckResult.FileExists) { this.BaseFolder.GetFileAsync(downloadPath).Result.DeleteAsync().Wait(); } fileExists = await this.BaseFolder.CheckExistsAsync(downloadPath); Assert.IsTrue(fileExists == ExistenceCheckResult.NotFound); await tu.DownloadAsync(downloadRequest); await VerifyDownloadedFile(downloadPath); // empty out file, except for 1 byte var file = await this.BaseFolder.GetFileAsync(downloadPath); await file.WriteAllTextAsync(testContent.Substring(0, 1)); await tu.DownloadAsync(downloadRequest); await VerifyDownloadedFile(downloadPath); }
IAsyncResult ICoreAmazonS3.BeginDownloadToFilePath(string bucketName, string objectKey, string filepath, IDictionary<string, object> additionalProperties, AsyncCallback callback, object state) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); return transfer.BeginDownload(request, callback, state); }
Task ICoreAmazonS3.DownloadToFilePathAsync(string bucketName, string objectKey, string filepath, IDictionary<string, object> additionalProperties, CancellationToken cancellationToken) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); return transfer.DownloadAsync(request, cancellationToken); }
void ICoreAmazonS3.DownloadToFilePath(string bucketName, string objectKey, string filepath, IDictionary<string, object> additionalProperties) { var transfer = new Amazon.S3.Transfer.TransferUtility(this); var request = new Amazon.S3.Transfer.TransferUtilityDownloadRequest { BucketName = bucketName, Key = objectKey, FilePath = filepath }; InternalSDKUtils.ApplyValues(request, additionalProperties); transfer.Download(request); }