Free Support Forum -

SharePoint StorageProvider



I need to integrate Viewer with Microsoft SharePoint 2013.
I saw a project in GitHub that shows how to do this, but didn’t like the way it was implemented.
What you did in the sample, is to create a copy of every viewed document in a local folder, and render the document from that folder. This is bad design for large scale systems.
This solution can lead to excessive disk usage, disk space, requires maintenance tasks, has some security implications, and is generally not very efficient. A much better solution is to directly read the file’s steam from SharePoint, as SharePoint provides an API for that.

I saw that the viewer has the concept of “Storage Provider” which is used to integrate with storage type, but I didn’t find any documentation for that.
Where can I find information about creating a custom Storage Provider?



Hello Itay,

Thank you for your request. GroupDocs.Viewer can work with stream, since that you don’t need to use a storage provider functional, you can just get a stream of the document and use it in the Viewer widget as described here .


Thanks, that was an interesting read.

So you have the option to use a stream as input, but the viewer still takes this stream and writes it to disk. This has the same issues as I described earlier…
Are there any other options? What about that Storage Provider? does it makes a local copy of the file as well?


Hello Itay,

GroupDocs.Viewer for .NET requires cache in all cases, without exception. When you open the document, GroupDocs.Viewer converts it to the HTML-representation: set of HTML markup, images, CSS, fonts, SVG, JavaScript and so on. In order to deliver maximum performance on a client-side, GroupDocs.Viewer doesn’t transfer all converted document to the browser - it sends only first few pages and loads other parts of documents on demand, when you want to browse especially that pages. That’s why cache is absolutely necessary.

There are two ways how the cache may be used. By default, GroupDocs.Viewer creates a cache in the “/temp” subfolder. Another way is to use the “IStorageProvider” approach. The class “Groupdocs.Web.UI.Viewer” contains a static method “SetStorageProvider”, which has the next overload:
public static void SetStorageProvider(IStorageProvider storageProvider, IStorageProvider tempStorageProvider);

If you specify this method, GroupDocs.Viewer will not use any files in the local folder at all: all operations will be done via storage provider.
First parameter, “storageProvider”, is responsible for obtaining and browsing documents, which should or can be displayed.
Second parameter, “tempStorageProvider”, is responsible for internal files, including cache.

Of course, this approach requires additional coding - you should implement the “IStorageProvider” interface by yourself. But this approach is very flexible and allows you to specify any storage of any kind.

So, in the Global.asax or where you want to initialize the GroupDocs.Viewer, you should have something like this:

IStorageProvider document_storage = new YourCustomStorageProviderForDocuments();
IStorageProvider cache_storage = new YourCustomStorageProviderForCache();
Viewer.SetStorageProvider(document_storage, cache_storage);

Here is a special version of the “GroupDocs.Viewer Sample Demo”. Inside the solution there is a project “GroupDocsViewerMVCDemo”. This project is modified - it uses the “IStorageProvider” implementation of the custom storage provider.

So, concluding, cache should exist in any case. If your implementation of the “IStorageProvider” will be incorrect, undefined and non-obvious errors may occur. This way requires maximum attention.


Thanks for the details response.

I will investigate that.