Reputation: 47
I would like to set Azure as backend for CKFinder and I want to read values (account, password) from AppSettings, not CKFinder setting for backend. smthng like:
<add key="CKFinderBackendAccountName" value="**********" />
<add key="CKFinderBackendAccountKey" value="************" />
So far I have this code and I want only Azure account, password to be read from APPSettings. I see no corresponding property in ConnectorBuilder.
connectorBuilder.LoadConfig()
.SetLicense(licenceDomain, licenceKey)
.SetAuthenticator(customAuthenticator)
.SetRequestConfiguration(
(request, config) =>
{
config.LoadConfig();
var defaultBackend = config.GetBackend("azureBackend");}
Upvotes: 2
Views: 164
Reputation: 3643
Yep this is possible using config.AddBackend() and config.AddResourceType()
var connector = connectorBuilder
.LoadConfig()
.SetRequestConfiguration(
(request, config) =>
{
config.LoadConfig();
string accountName = ConfigurationManager.AppSettings["CKFinderBackendAccountName"];
string accountKey = ConfigurationManager.AppSettings["CKFinderBackendAccountKey"];
// For saving images and files
var azStorage = new AzureStorage(accountName, accountKey, "containername", "rootname");
config.AddBackend("azstore", azStorage, baseUrl: "https://storageaccountname.blob.core.windows.net/ckfinderstuff", isProxy: false);
config.AddResourceType("Images", resourceBuilder => resourceBuilder.SetBackend("azstore", "images").SetAllowedExtensions("bmp", "gif", "jpeg", "jpg", "png"));
config.AddResourceType("Files", resourceBuilder => resourceBuilder.SetBackend("azstore", "files").SetAllowedExtensions("7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "docx", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pptx", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "xlsx", "zip"));
})
.SetAuthenticator(customAuthenticator)
.Build(connectorFactory);
You need to make sure you delete the backend
and resourceTypes
node under the ckfinder
section in web.config
There isn't much documentation around this so I had to figure most of it out myself but you can see if the documentation here helps
https://ckeditor.com/docs/ckfinder/ckfinder3-net/configuration_by_code.html
Upvotes: 0