CKFinder is an Ajax application with a frontend written entirely in JavaScript. It communicates with the server through JSON messages. On the server side, there is a "connector" written in a specific server language, which handles the frontend requests. The following diagram illustrates it:
The CKFinder 3 for ASP.NET connector is divided into the following NuGet libraries:
Each application should reference at least the following packages:
This package contains the JavaScript part of CKFinder.
Support for the configuration file. Handles both application configuration (Web.config
, App.config
) and standalone file types.
Exports the CKSource.CKFinder.Connector.Config namespace.
The most important LoadConfig method is implemented in the ConnectorBuilderConfigExtensions class. It is important to register all available file systems in the FileSystemFactory class before calling LoadConfig.
The core library responsible for handling commands, publishing events and loading plugins.
Exports the CKSource.CKFinder.Connector.Core namespace.
The most important class included in this package is ConnectorBuilder which should be used to set up the connector.
A group of possible hosting packages. CKFinder may be hosted in Owin or in a WebApi environment.
Only one of these packages should be used in a project.
Hosting in Owin environment.
Exports the CKSource.CKFinder.Connector.Host.Owin namespace.
The most important class included in this package is OwinConnectorFactory which should be used to build the connector in the Build method.
Packages that provide various adapters for the key-value store. CKFinder uses key-value stores for caching.
Only one of these packages should be used in a project.
File system based adapter for the key-value store.
Exports the CKSource.CKFinder.Connector.KeyValue.FileSystem namespace.
Provides FileSystemKeyValueStoreProvider.
An entity framework adapter for the key-value store.
Important: This key-value store adapter may cause performance issues and is deprecated. Please use CKSource.CKFinder.Connector.KeyValue.FileSystem instead.
Exports the CKSource.CKFinder.Connector.KeyValue.EntityFramework namespace.
Provides EntityFrameworkKeyValueStoreProvider.
NLog adapter for logging in CKFinder.
Exports CKSource.CKFinder.Connector.Logs.NLog namespace.
The most important class included in this package is NLogLoggerAdapterFactory which should be provided to the LoggerManager.LoggerAdapterFactory property.
Common classes for all file systems.
Exports the CKSource.FileSystem namespace.
An Amazon S3 file system adapter.
Exports the CKSource.FileSystem.Amazon namespace.
An Azure Storage file system adapter.
Exports the CKSource.FileSystem.Azure namespace.
A Dropbox file system adapter.
Exports the CKSource.FileSystem.Dropbox namespace.
A FTP file system adapter.
Exports the CKSource.FileSystem.Ftp namespace.
A local file system adapter.
Exports the CKSource.FileSystem.Local namespace.
The CKFinder ASP.NET connector provides a set of events that can be used for changing the default application behavior. Each of the events is identified by its unique type, and can be listened to by any number of listeners.
To attach a listener to the event, you can use the event aggregator object stored in the application dependency injection container:
It is possible to stop event propagation by not calling the next event handler.
To remove an event listener, call the Unsubscribe method:
Unsubscription may be done in the event handler itself.
These events are fired after a particular command is resolved, i.e. it is decided which command class should be used to handle the current request.
The parameter passed to event listeners is an object of the BeforeCommandEvent type that carries the following information:
In event listeners it is possible to provide any additional code that will be executed before the command.
To check which command fired the event you should compare the type of the instance of the command with command types:
The full list of built-in commands is presented in a table below:
Command Type | Description |
---|---|
CopyFiles | Copies files from selected folders. |
CreateFolder | Creates a child folder. |
DeleteFiles | Deletes given files. |
DeleteFolder | Deletes a given folder. |
DownloadFile | Downloads a file from the server. |
FileUpload | Uploads a file to a given folder. |
GetFiles | Returns the list of files for a given folder. |
GetFileUrl | Returns a direct URL to a file. |
GetFolders | Returns the list of the child folders for a given folder. |
GetResizedImages | Returns a list of resized versions of the image file. |
ImageEdit | Performs basic image modifications: crop, rotate, resize. |
ImageInfo | Returns information about the dimensions of the image file. |
ImagePreview | Creates a resized version of the image file. |
ImageResize | Creates a resized version of the image file. |
Init | This is the first command issued by CKFinder. It returns the general settings of the connector and all configured resource types. |
MoveFiles | Moves files from selected folders. |
Operation | Tracks the progress of the operation in time-consuming connector commands. |
Proxy | Serves a file to the browser without forcing the download. This command is useful in cases where you want to use files without direct access on a web page. These may be files stored on a backend like a private FTP server, or files that are not in the web server root folder. If the backend is defined as a Proxy , all links generated by CKFinder will be pointing to the Proxy command. |
QuickUpload | Uploads a file to the given folder. This command is very similar to FileUpload and it is used to handle uploads from the CKEditor Image or Link dialog window. |
RenameFile | Renames a file. |
RenameFolder | Renames a folder. |
SaveImage | Saves a Base64-encoded PNG image to a file. |
Thumbnail | Downloads the thumbnail of an image file. |
These events are fired inside command classes before any important operations such as uploading a file, renaming, deleting, or moving files and folders take place.
Command | Event Type | Notes |
---|---|---|
CopyFiles | CopyFileEvent | Fired for every file being copied |
CreateFolder | CreateFolderEvent | - |
DeleteFiles | DeleteFileEvent | Fired for every file being deleted |
DeleteFolder | DeleteFolderEvent | - |
DownloadFile | DownloadFileEvent | - |
FileUpload | FileUploadEvent | - |
GetFiles | - | - |
GetFileUrl | - | - |
GetFolders | - | - |
GetResizedImages | - | - |
ImageEdit | ImageEditEvent | - |
ImageInfo | - | - |
ImagePreview | - | - |
ImageResize | ResizeImageEvent | - |
Init | - | - |
MoveFiles | MoveFileEvent | Fired for every file being moved |
Operation | - | - |
Proxy | ProxyDownloadEvent | - |
QuickUpload | FileUploadEvent | - |
RenameFile | RenameFileEvent | - |
RenameFolder | RenameFolderEvent | - |
SaveImage | SaveImageEvent | - |
Thumbnail | - | - |
These events are fired after a particular command returned the response.
The parameter passed to event listeners is an object of the AfterCommandEvent type that carries the following information:
In events listeners it is possible to provide any additional code that will be executed after the command, but it is also possible to replace the command result object that is carried inside the event object, so the new provided response object will be used instead.
To check which command fired the event see description of BeforeCommand Events.