public Task <object> GeneratePreviewAsync(DocumentDetailDto model, long userId, CancellationToken token) { var result = Enumerable.Range(0, model.Pages).Select(i => { var uri = _blobProvider.GetPreviewImageLink(model.Document.Id, i); var effect = ImageProperties.BlurEffect.None; if (!model.IsPurchased) { effect = ImageProperties.BlurEffect.All; if (i == 0 || i == 1) { effect = ImageProperties.BlurEffect.None; } } var properties = new ImageProperties(uri, effect); var hash = _binarySerializer.Serialize(properties); return(_linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "imageUrl", new { hash = Base64UrlTextEncoder.Encode(hash) })); }); return(Task.FromResult <object>(result)); }
public async Task <object> GeneratePreviewAsync(DocumentDetailDto model, long userId, CancellationToken token) { string locator; if (model.IsPurchased) { locator = await _videoService.BuildUserStreamingLocatorAsync(model.Document.Id, userId, token); } else { locator = await _videoService.GetShortStreamingUrlAsync(model.Document.Id, token); } var uri = _urlBuilder.BuildDocumentThumbnailEndpoint(model.Document.Id); return(new { locator, poster = uri }); }
public DocumentPreviewResponse(DocumentDetailDto details, object preview, string content) { Details = details; Content = content; Preview = preview; }