private Stream GetFileStream(string documentId, string ownerId) { var libraryLocation = _folderManager.GetDocumentLibraryAsync(ownerId).Result.Location; var document = _docService.GetAsync(documentId).Result; var result = _ulService.GetFileStreamAsync(document, libraryLocation).Result; return(result); }
private async Task <Stream> DownloadDocumentAsync(FileDocument document, string userId) { Ensure.NotNull(document, $"{nameof(document)} cannot be null."); var physicalLocation = await GetLibraryPhysicalLocation(document.DocumentId); var result = await _uploadService.GetFileStreamAsync(document, physicalLocation); await _log.LogEventReadAsync(document, userId); return(result); }
private async void EnsurePhysicalFile(FileDocument doc, string libraryLocation) { var stream = await _uploadService.GetFileStreamAsync(doc, libraryLocation); if (stream == null) { using (stream = CreateTemporarySeedData(doc)) { if (stream.Length > 0) { await _uploadService.SetFileStreamAsync(doc, stream, libraryLocation); } } } else { stream.Dispose(); } }