/// <summary> /// Returns a <see cref="System.Threading.Tasks.Task<IAsset>"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>. /// </summary> /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param> /// <param name="filePath">The path to the file to upload to the new <see cref="IAsset"/>.</param> /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param> /// <param name="options">The <see cref="AssetCreationOptions"/>.</param> /// <param name="uploadProgressChangedCallback">A callback to report the upload progress of the file.</param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param> /// <returns>A <see cref="System.Threading.Tasks.Task<IAsset>"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.</returns> public static Task<IAsset> CreateFromFileAsync(this AssetBaseCollection assets, string filePath, IAccountSelectionStrategy strategy, AssetCreationOptions options, Action<IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback, CancellationToken cancellationToken) { if (strategy == null) { throw new ArgumentNullException("strategy"); } string storageAccountName = strategy.SelectAccountForAsset(); return assets.CreateFromFileAsync(filePath, storageAccountName, options, uploadProgressChangedCallback, cancellationToken); }
/// <summary> /// Returns a <see cref="System.Threading.Tasks.Task<IAsset>"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>. /// </summary> /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param> /// <param name="filePath">The path to the file to upload to the new <see cref="IAsset"/>.</param> /// <param name="options">The <see cref="AssetCreationOptions"/>.</param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param> /// <returns>A <see cref="System.Threading.Tasks.Task<IAsset>"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.</returns> public static Task<IAsset> CreateFromFileAsync(this AssetBaseCollection assets, string filePath, AssetCreationOptions options, CancellationToken cancellationToken) { return assets.CreateFromFileAsync(filePath, options, null, cancellationToken); }
/// <summary> /// Returns a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>. /// </summary> /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param> /// <param name="filePath">The path to the file to upload to the new <see cref="IAsset"/>.</param> /// <param name="storageAccountName">The name of the storage account where to store the new <see cref="IAsset"/>.</param> /// <param name="options">The <see cref="AssetCreationOptions"/>.</param> /// <param name="uploadProgressChangedCallback">A callback to report the upload progress of the file.</param> /// <returns>A new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.</returns> public static IAsset CreateFromFile(this AssetBaseCollection assets, string filePath, string storageAccountName, AssetCreationOptions options, Action<IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback) { using (Task<IAsset> task = assets.CreateFromFileAsync(filePath, storageAccountName, options, uploadProgressChangedCallback, CancellationToken.None)) { return task.Result; } }
/// <summary> /// Returns a <see cref="System.Threading.Tasks.Task<IAsset>"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>. /// </summary> /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param> /// <param name="filePath">The path to the file to upload to the new <see cref="IAsset"/>.</param> /// <param name="options">The <see cref="AssetCreationOptions"/>.</param> /// <param name="uploadProgressChangedCallback">A callback to report the upload progress of the file.</param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param> /// <returns>A <see cref="System.Threading.Tasks.Task<IAsset>"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.</returns> public static Task<IAsset> CreateFromFileAsync(this AssetBaseCollection assets, string filePath, AssetCreationOptions options, Action<IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback, CancellationToken cancellationToken) { return assets.CreateFromFileAsync(filePath, (string)null, options, uploadProgressChangedCallback, cancellationToken); }