We would like to use GroupDocs.Viewer to display documents stored in our proprietary repository. It looks like the IStorageProvider interface is the way to achieve this, but the documentation is a bit sparse.
There is a sample mentioned in this thread http://groupdocs.com/Community/forums/3724/sharepoint-storageprovider/showthread.aspx#3724 but the DropBox link is no longer valid, could you provide it again?
Also, the following information would be very helpful:
- What is the minimum set of methods we need to implement to get a “read-only” storage provider with no browsing (i.e. “Open” button is disabled in client)? What is the sequence of calls?
- Is there a way to call Viewer.SetStorageProvider to provide a custom implementation for retrieving documents from the repository, but use the default filesystem implementation for the cache/temporary folder? This should reduce the amount we need to implement I think.
Thank you for your interest in GroupDocs.Viewer for .NET. Yes, it supports custom storage provider, which should implement the “IStorageProvider” interface.
1. Here is the link for the updated solution. Sample project is “GroupDocsViewerMVCDemo”, it demonstrates, how to use custom storage provider. In the “Application_Start” method of the Global.asax you can see, how the custom storage provider is specified. Two instances of custom storage provider are created: first for the documents and second for the cache. The custom storage provider is declared in the “CustomStorageProvider.cs” file - it actually is a wrapper around “AzureFileStorage” class. “AzureFileStorage” constructor, in turn, obtains the MS Azure credentials. When you will download this project, you’ll see standard credentials for the Azure Emulator; if it is installed on your machine, you can launch the project without modifying it. Otherwise, if you don’t have Azure Emulator installed on your machine, you will obtain this exception.
2. All methods in the “IStorageProvider” interface are mandatory, except two: “public Stream CreateFile(string path)” and “public FileSystemEntity ListEntities(string path)”. First one is responsible for uploading a new document to the server, and second - for obtaining a list of documents on the server. If you don’t want to implement “ListEntities” method, you should also disable a “Open file” button in the toolbar.
3. Yes, this is possible. Basically, when you don’t use custom or remote storage provider, GroupDocs.Viewer uses own “Groupdocs.Storage.LocalFileStorage” provider. This class is public, so you also can use it. It doesn’t implement the “IStorageProvider” interface, so you need to create a wrapper for the “Groupdocs.Storage.LocalFileStorage”, which should implement “IStorageProvider”. And then specify this wrapper as the second parameter in the “Viewer.SetStorageProvider” static method.
If you will have more questions please feel free to contact us.
Thanks, that should prove useful. However, there was a miscommunication between two of our teams as to whether the back-end repository was actually ready, so we will be going with the standard folder-based storage in the short term, and it will be a couple of months before we start to use IStorageProvider
Hello Phil, thanks for answering, we are glad that our post was helpful. If you have some additional questions about custom storage provider or anything else, please feel free to contact us.