public override async Task <bool> DeleteAsync(BlobProviderDeleteArgs args) { var blobName = AzureBlobNameCalculator.Calculate(args); if (await BlobExistsAsync(args, blobName)) { return(await GetBlobClient(args, blobName).DeleteIfExistsAsync()); } return(false); }
public override async Task <Stream> GetOrNullAsync(BlobProviderGetArgs args) { var blobName = AzureBlobNameCalculator.Calculate(args); if (!await BlobExistsAsync(args, blobName)) { return(null); } var blobClient = GetBlobClient(args, blobName); var download = await blobClient.DownloadAsync(); return(await TryCopyToMemoryStreamAsync(download.Value.Content, args.CancellationToken)); }
public override async Task SaveAsync(BlobProviderSaveArgs args) { var blobName = AzureBlobNameCalculator.Calculate(args); var configuration = args.Configuration.GetAzureConfiguration(); if (!args.OverrideExisting && await BlobExistsAsync(args, blobName)) { throw new BlobAlreadyExistsException($"Saving BLOB '{args.BlobName}' does already exists in the container '{GetContainerName(args)}'! Set {nameof(args.OverrideExisting)} if it should be overwritten."); } if (configuration.CreateContainerIfNotExists) { await CreateContainerIfNotExists(args); } await GetBlobClient(args, blobName).UploadAsync(args.BlobStream, true); }
public override async Task <Stream> GetOrNullAsync(BlobProviderGetArgs args) { var blobName = AzureBlobNameCalculator.Calculate(args); if (!await BlobExistsAsync(args, blobName)) { return(null); } var blobClient = GetBlobClient(args, blobName); var download = await blobClient.DownloadAsync(); var memoryStream = new MemoryStream(); await download.Value.Content.CopyToAsync(memoryStream); return(memoryStream); }
public override async Task <bool> ExistsAsync(BlobProviderExistsArgs args) { var blobName = AzureBlobNameCalculator.Calculate(args); return(await BlobExistsAsync(args, blobName)); }