private async Task <DocumentAssetFile> GetDocumentAssetFile(int assetId) { DocumentAssetFile file = null; try { var query = new GetDocumentAssetFileByIdQuery(assetId); file = await _queryExecutor.ExecuteAsync(query); } catch (FileNotFoundException ex) { // If the file exists but the file has gone missing, log and return a 404 _logger.LogError(0, ex, "Document Asset exists, but has no file: {0}", assetId); } return(file); }
public async Task <ActionResult> File(int assetId, string fileName, string extension) { DocumentAssetFile file = null; try { var query = new GetDocumentAssetFileByIdQuery(assetId); file = await _queryExecutor.ExecuteAsync(query); } catch (FileNotFoundException ex) { // If the file exists but the file has gone missing, log and return a 404 _logger.LogError(0, ex, "Document Asset exists, but has no file: {0}", assetId); } if (file == null) { return(FileAssetNotFound("File not found")); } return(File(file.ContentStream, file.ContentType, file.FileName)); }
public IDomainRepositoryQueryContext <DocumentAssetFile> AsFile() { var query = new GetDocumentAssetFileByIdQuery(_documentAssetId); return(DomainRepositoryQueryContextFactory.Create(query, ExtendableContentRepository)); }