public async Task <BlobContent> ReadBlobContentAsync(long tenantId, long elementId, long blobSetId, string blobLabel)
        {
            HtmlElementSettings settings = await _elementRepository.ReadElementSettingsAsync(tenantId, elementId);

            if (settings == null)
            {
                return(null);
            }

            HtmlBlobSet blobSet = settings.BlobSets.Where(s => s.BlobSetId == blobSetId).FirstOrDefault();

            if (blobSet == null)
            {
                return(null);
            }

            long?blobId = GetBlobId(blobSet, blobLabel);

            if (blobId == null)
            {
                return(null);
            }

            return(await _storageService.ReadBlobContentAsync(tenantId, blobId.Value, GetHtmlImagePath(elementId)));
        }
        private HtmlPreviewImage GetHtmlPreviewImageFromHtmlBlob(HtmlBlobSet blobSet, IDictionary <long, BlobImage> blobsById)
        {
            BlobImage blobImage = blobsById[blobSet.PreviewImageBlobId];

            return(new HtmlPreviewImage
            {
                BlobSetId = blobSet.BlobSetId,
                Width = blobImage.Width,
                Height = blobImage.Height,
                Name = blobImage.Name
            });
        }
        private long?GetBlobId(HtmlBlobSet blobSet, string blobLabel)
        {
            switch (blobLabel)
            {
            case OriginalBlobLabel:
                return(blobSet.ImageBlobId);

            case PreviewBlobLabel:
                return(blobSet.PreviewImageBlobId);

            case ThumbnailBlobLabel:
                return(blobSet.ThumbnailImageBlobId);

            default:
                return(blobSet.PreviewImageBlobId);
            }
        }