@mohantriyam
I’m sorry for the delayed response.
Yes, it is possible to store the source files and output files in memory. Please find the sample-app.zip (4.5 KB) that demonstrates how you can implement custom file storage that is responsible for reading a file from any source without storing it to the local disk. Here is a complete listing of the Startup.cs
:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using GroupDocs.Viewer.UI.Core;
using GroupDocs.Viewer.UI.Core.Entities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace GroupDocs.Viewer.AspNetCore
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IFileStorage, MyFileStorage>();
services
.AddGroupDocsViewerUI();
services
.AddControllers()
.AddGroupDocsViewerSelfHostApi()
.AddInMemoryCache(config => config
.SetGroupCacheEntriesByFile(true)
.SetCacheEntryExpirationTimeoutMinutes(5)
);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app
.UseRouting()
.UseEndpoints(endpoints =>
{
endpoints.MapGroupDocsViewerUI(options =>
{
options.UIPath = "/viewer";
options.APIEndpoint = "/viewer-api";
});
endpoints.MapGroupDocsViewerApi(options =>
{
options.ApiPath = "/viewer-api";
});
});
}
}
public class MyFileStorage : IFileStorage
{
public Task<IEnumerable<FileSystemEntry>> ListDirsAndFilesAsync(string dirPath)
{
var entries = new List<FileSystemEntry> {
FileSystemEntry.File("sample.txt", "sample.txt", 123)
};
return Task.FromResult<IEnumerable<FileSystemEntry>>(entries);
}
public Task<string> WriteFileAsync(string fileName, byte[] bytes, bool rewrite)
{
throw new NotImplementedException("Implement this method to support file upload.");
}
public Task<byte[]> ReadFileAsync(string filePath)
{
//TODO: read your file here and return bytes
var bytes = Encoding.UTF8
.GetBytes("File path: " + filePath);
return Task.FromResult(bytes);
}
}
}
Run the application with dotnet run
and navigate to https://localhost:9091/viewer
in your browser. Browse the files using Folder icon and select a single sample.txt
file. The file will be rendered in memory and never stored on the local disk. When the rendering will be finished the following page should appear

Please let us know if it works for you.