I need an example on how to pull a file from Azure to view in this control and to limit the functionality in the ImageEditor to not allow upload and download. I use your PDF Viewer so based on that example, this is what I have:
Controller:
[HttpGet]
public async Task<FileStreamResult> DownloadFileFromBlobStorage(int id)
{
...
if (currentContainer.Container != null)
{
BlobContainerClient blobContainerClient =
currentContainer.Container.Name.GetContainer();
if (await blobContainerClient.ExistsAsync())
{
if (await blobContainerClient.BlobExists(currentContainer.Path))
{
Stream stream =
await blobContainerClient.GetStream(
currentContainer.Path);
stream.Position = 0;
return File(stream, contentType);
}
else
{
throw new Exception("File not found in Azure container for this record");
}
}
else
{
throw new Exception(
$"Unable to capture Azure container: {currentContainer.Container.Name}");
}
}
}
View:
pdfViewer works... I need help with the imageEditor:
@if (Model.Item.Extension.ToLower() == Glossary.PdfExtension)
{
<div>
@(Html.Kendo().PDFViewer()
.Name("pdfviewer2")
.PdfjsProcessing(pdf => pdf.File(""))
.Toolbar(toolbar =>
{
toolbar.Items(items =>
{
items.Add().Name("pager");
items.Add().Name("spacer");
items.Add().Name("zoom");
items.Add().Name("toggleSelection");
items.Add().Name("spacer");
items.Add().Name("search");
items.Add().Name("download");
items.Add().Name("print");
});
})
)
</div>
}
else if (Model.Item.Extension.ToLower() == Glossary.PngExtension)
{
<div>
@(Html.Kendo().ImageEditor()
.Name("imageEditor")
.Height(900)
... how to load image from FileStreamResult
)
</div>
}
View Script:
$(document).ready(function() {
var pdfViewer = $("#pdfviewer2").data("kendoPDFViewer");
// pdfViewer is not rendered unless the file extension is PDF
if (pdfViewer != null) {
var handlerUrlPdf = "/Pdfs/DownloadFileFromBlobStorage/" + @Model.Item.Id + "/" + @Glossary.Pdf;
pdfViewer.fromFile(handlerUrlPdf);
}
var imageViewer = $("#imageEditor").data("kendoImageEditor");
if (imageViewer != null) {
var handlerUrlPng = "/Pdfs/DownloadFileFromBlobStorage/" + @Model.Item.Id + "/" + @Glossary.Image;
imageViewer.fromFile(handlerUrlPng);
}
});