Streaming files from different storages

Hi Team,

Currently, we are using GroupDocs viewer 18.1.0 for rendering our documents in our ASP.NET MVC application. The current strategy involves downloading the documents from the different storages (Amazon S3, FTP, SFTP) into the webserver and rendering those documents via the viewer. Now we would like to render the documents directly into the viewer without downloading them into the server. Could you please let us know if the 18th version supports the same or do we need to upgrade version to the latest? If the current version supports the same, please provide some information on the same. Also we would like to use the same strategy to render documents directly from Azure blob storage. Please advise.

@samphu_nath

I’m sorry for the delayed response. We’re investigating this scenario and will update you as soon as we have any information.

@samphu_nath

The 18.1.0 supports rendering documents from a stream

string fileName = "sample.doc";
MemoryStream stream = GetFileStream(fileName);

ViewerHtmlHandler handler = new ViewerHtmlHandler();
List<PageHtml> pages = handler.GetPages(stream, fileName);

foreach (var page in pages)
{
    string htmlFileName = $"p-{page.PageNumber}.html";
    string htmlFilePath = Path.Combine(outputDir, htmlFileName);

    File.WriteAllText(htmlFilePath, page.HtmlContent);
}

GetFileStream method may return any Stream e.g. MemoryStream; This enables you to store a file in memory instead of a local disk. Make sure to read all the file bytes into memory, since network streams that enable reading data in chunks are not supported by Viewer.

Looking forward to your response.