|
||
The purpose of the CMS.IO library is to provide an easy way of customizing Kentico CMS to support a file system of your choice. As described in the Overview topic, you can achieve this by developing a custom provider based on the classes contained within CMS.IO.
A generic storage provider project is available in the CodeSamples directory in your Kentico CMS installation (e.g. C:\Program Files (x86)\Kentico CMS\7.0). The project contains definitions of all required classes and their members for easy implementation.
1. Copy the generic project folder (CustomFileSystemProvider) into your web project folder.
2. Choose to add an existing project to your web project solution and select the custom storage provider.
3. Add CMS.IO reference to the new project.
4. Add the project reference to your web project.
If you choose to take advantage of the prepared provider, go through all files contained in the project and replace the NotImplementedExceptions inside methods with your implementation and implement property and method overrides. You can consult the following steps for reference or if you wish to create a provider from scratch.
1. Create classes that will inherit from the following abstract classes:
•CMS.IO.AbstractDirectory
•CMS.IO.AbstractFile
2. Implement all methods defined in those abstract classes.
3. Create classes that will inherit from the following classes:
•CMS.IO.DirectoryInfo
•CMS.IO.FileInfo
•CMS.IO.FileStream
4. Override all methods and properties from those classes.
5. Create constructors for the classes listed previously according to the following table:
Inherits from |
Constructors |
CMS.IO.DirectoryInfo |
•public DirectoryInfo(string path) |
CMS.IO.FileInfo |
•public FileInfo(string filename) |
CMS.IO.FileStream |
•public FileStream(string path, CMS.IO.FileMode mode) •public FileStream(string path, CMS.IO.FileMode mode, CMS.IO.FileAccess access) •public FileStream(string path, CMS.IO.FileMode mode, CMS.IO.FileAccess access, CMS.IO.FileShare share) •public FileStream(string path, CMS.IO.FileMode mode, CMS.IO.FileAccess access, CMS.IO.FileShare share, int bSize) |
To start using your custom provider, you need to make configuration changes in your web.config file.
1. Add the CMSStorageProviderAssembly key to the appSettings section and set its value to the assembly name of your custom provider.
2. Add the CMSExternalStorageName key to the appSettings section. You can choose any string of characters as a value. The value will be used in code to determine whether the application uses an external storage. See Using CMS.IO for more information about the code that processes the storage name.
For example, if you named the project "CustomFileSystemProvider" and the provider name is "custom", the code inserted into the web.config file will look like the following:
<appSettings> ... <add key="CMSStorageProviderAssembly" value="CustomFileSystemProvider" /> <add key="CMSExternalStorageName" value="custom" /> ... </appSettings> |
After you save the web.config, the system starts using your custom provider.