public async Task UploadFileAsync( string localPath, string storagePath, IProgress <StorageProgressDto> progress, CancellationToken cancellationToken) { var data = File.ReadAllBytes(localPath); var pathInParts = PathExtensions.GetPathInParts(storagePath, '/'); var fileName = pathInParts.PopLast(); var fullStoragePath = PathExtensions.Combine(string.Empty, pathInParts, "/"); await _storageProvider.UploadDirectoriesAsync(pathInParts.PopFirst(), new FileEntryDto(pathInParts), progress, cancellationToken).ConfigureAwait(false); await _storageProvider .UploadFileAsync(data, fullStoragePath, fileName, progress, cancellationToken) .ConfigureAwait(false); }
private Func <FileEntryDto, Task> UploadConcurrentDirectoriesAsync( string storagePath, SemaphoreSlim semaphore, IProgress <StorageProgressDto> progress, CancellationToken cancellationToken) { return(async directory => { await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); try { await _storageProvider.UploadDirectoriesAsync(storagePath, directory, progress, cancellationToken) .ConfigureAwait(false); } finally { semaphore.Release(); } }); }