This page is a considered
complete and accurate. However, if you find an error, please take the time
report it.
In this short article we are going to learn how to write a simple Files Storage Provider for ScrewTurn Wiki 3.0 (STW from now on). A Files Storage Provider is a type of plugin that handles files-related data such as uploaded files/directories and page attachments
Introduction to Files Storage Providers
This brief section assumes you have already a
general knowledge on STW providers.
The main task a Files Storage Provider performs is handling the following data on behalf of the wiki application:
- upload directories
- upload files
- page attachments.
Note: in case of
read-only data (
ReadOnly property returning
true) the wiki application should never call methods that are intended for altering data. However, such methods that return collections should return empty collections instead of
null. Methods that return single elements should return
null instead.
All paths are specified in a UNIX-like format, for example
/path/to/file.txt, but all paths are
case-insensitive. All paths must start with a slash, and all directory paths must end with a slash too.
Important note: all providers should be totally thread-safe.
Directories Management
The following methods are called by the wiki application to manage directories:
ListDirectories lists directories inside the specified directoryCreateDirectory creates a directory inside the specified directoryDeleteDirectory deletes a directory and all data inside it (files and sub-directories)RenameDirectory renames a directory.
Files Management
The following methods are called by the wiki application to manage files:
ListFiles lists files inside the specified directoryStoreFile stores a file inside the specified directory, reading from a source Stream and optionally counting the downloadRetrieveFile retrieves a file, writing into a destination StreamGetFileDetails returns an instance of FileDetails (or null if the file does not exist) containing information about the file (such as the size and number of downloads)SetFileRetrievalCount sets the number of times a file has been downloadedDeleteFile deletes a file and its download countRenameFile renames a file, preserving its download count.
Page Attachment Management
The following methods are called by the wiki application to manage page attachments:
GetPagesWithAttachments lists the names of the pages that have at least one attachmentListPageAttachments lists the attachments a page hasStorePageAttachment stores an attachment for the specified page, reading from a source StreamRetrievePageAttachment retrieves an attachment for the specified page, writing to a destination Stream and optionally counting the downloadGetPageAttachmentDetails returns an instance of FileDetails (or null if the attachment does not exist}} containing information about the attachment (such as the size and number of downloads)SetPageAttachmentRetrievalCount sets the number of time an attachment has been downloadedDeletePageAttachment deletes a page attachment and its download countRenamePageAttachment renames a page attachment, preserving its download countNotifyPageRenaming is called when a page is renamed (the provider should use this information to preserve the attachments data as well as their download count).