/// <summary> /// Download an Azure blob directory from Azure Blob Storage. /// </summary> /// <param name="sourceBlobDir">The <see cref="CloudBlobDirectory"/> that is the source Azure blob directory.</param> /// <param name="destPath">Path to the destination directory</param> /// <param name="options">A <see cref="DownloadDirectoryOptions"/> object that specifies additional options for the operation.</param> /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> object to observe while waiting for a task to complete.</param> /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns> public static Task DownloadDirectoryAsync(CloudBlobDirectory sourceBlobDir, string destPath, DownloadDirectoryOptions options, TransferContext context, CancellationToken cancellationToken) { AzureBlobDirectoryLocation sourceLocation = new AzureBlobDirectoryLocation(sourceBlobDir); DirectoryLocation destLocation = new DirectoryLocation(destPath); AzureBlobEnumerator sourceEnumerator = new AzureBlobEnumerator(sourceLocation); if (options != null) { sourceEnumerator.SearchPattern = options.SearchPattern; sourceEnumerator.Recursive = options.Recursive; sourceEnumerator.IncludeSnapshots = options.IncludeSnapshots; BlobRequestOptions requestOptions = Transfer_RequestOptions.DefaultBlobRequestOptions; requestOptions.DisableContentMD5Validation = options.DisableContentMD5Validation; sourceLocation.BlobRequestOptions = requestOptions; } return DownloadDirectoryInternalAsync(sourceLocation, destLocation, sourceEnumerator, context, cancellationToken); }
/// <summary> /// Copy an Azure blob directory to an Azure file directory. /// </summary> /// <param name="sourceBlobDir">The <see cref="CloudBlobDirectory"/> that is the source Azure blob directory.</param> /// <param name="destFileDir">The <see cref="CloudFileDirectory"/> that is the destination Azure file directory.</param> /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not. /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false, /// file is downloaded from source first, then uploaded to destination.</param> /// <param name="options">A <see cref="CopyDirectoryOptions"/> object that specifies additional options for the operation.</param> /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> object to observe while waiting for a task to complete.</param> /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns> public static Task CopyDirectoryAsync(CloudBlobDirectory sourceBlobDir, CloudFileDirectory destFileDir, bool isServiceCopy, CopyDirectoryOptions options, TransferContext context, CancellationToken cancellationToken) { AzureBlobDirectoryLocation sourceLocation = new AzureBlobDirectoryLocation(sourceBlobDir); AzureFileDirectoryLocation destLocation = new AzureFileDirectoryLocation(destFileDir); AzureBlobEnumerator sourceEnumerator = new AzureBlobEnumerator(sourceLocation); if (options != null) { sourceEnumerator.SearchPattern = options.SearchPattern; sourceEnumerator.Recursive = options.Recursive; sourceEnumerator.IncludeSnapshots = options.IncludeSnapshots; } return CopyDirectoryInternalAsync(sourceLocation, destLocation, isServiceCopy, sourceEnumerator, options, context, cancellationToken); }