Exemplo n.º 1
0
        private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create a connector instance using ConnectorBuilder. The call to the LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            /*
             * Create an instance of authenticator implemented in the previous step.
             */
            var customAuthenticator = new CustomCKFinderAuthenticator();


            connectorBuilder

            /*
             * Provide the global configuration.
             *
             * If you installed CKSource.CKFinder.Connector.Config, you should load the static configuration
             * from XML:
             * connectorBuilder.LoadConfig();
             */
            .LoadConfig()
            .SetAuthenticator(customAuthenticator)
            .SetRequestConfiguration(
                (request, config) =>
            {
                /*
                 * If you installed CKSource.CKFinder.Connector.Config, you might want to load the static
                 * configuration from XML as a base configuration to modify:
                 */
                config.LoadConfig();

                /*
                 * Configure settings per request.
                 *
                 * The minimal configuration has to include at least one backend, one resource type
                 * and one ACL rule.
                 *
                 * For example:
                 */
                //config.AddBackend("default", new LocalStorage(@"C:\files"));
                config.AddResourceType("images", builder => builder.SetBackend("default", "images"));
                config.AddAclRule(new AclRule(
                                      new StringMatcher("*"),
                                      new StringMatcher("*"),
                                      new StringMatcher("*"),
                                      new Dictionary <Permission, PermissionType> {
                    { Permission.All, PermissionType.Allow }
                }));


                /*
                 * If you installed CKSource.CKFinder.Connector.KeyValue.FileSystem, you may enable caching:
                 */
                var defaultBackend        = config.GetBackend("default");
                var keyValueStoreProvider = new FileSystemKeyValueStoreProvider(defaultBackend);
                config.SetKeyValueStoreProvider(keyValueStoreProvider);
            }
                );

            /*
             * Build the connector middleware.
             */
            var connector = connectorBuilder
                            .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to the web application pipeline.
             */
            app.UseConnector(connector);
        }
Exemplo n.º 2
0
        private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create a connector instance using ConnectorBuilder. The call to the LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            /*
             * Create an instance of authenticator implemented in the previous step.
             */
            var customAuthenticator = new CustomCKFinderAuthenticator();

            connectorBuilder

            /*
             * Provide the global configuration.
             *
             * If you installed CKSource.CKFinder.Connector.Config you may load static configuration
             * from XML:
             * connectorBuilder.LoadConfig();
             */
            .LoadConfig()
            .SetAuthenticator(customAuthenticator)
            .SetRequestConfiguration(
                (request, config) =>
            {
                /* Add a local backend. */
                //config.AddProxyBackend("local", new LocalStorage(@"public/upload"));
                config.AddBackend("local", new LocalStorage(@"public/upload", "http://www.stampecreative.it/public/upload/"));
                /* Add a resource type that uses the local backend. */
                config.AddResourceType("Files", resourceBuilder => resourceBuilder.SetBackend("local", "files"));
                config.AddResourceType("Images", resourceBuilder => resourceBuilder.SetBackend("local", "images"));
                /* Give full access to all resource types at any path for all users. */
                config.AddAclRule(new AclRule(
                                      new StringMatcher("*"), new StringMatcher("/"), new StringMatcher("*"),
                                      new Dictionary <Permission, PermissionType>
                {
                    { Permission.FolderView, PermissionType.Allow },
                    { Permission.FolderCreate, PermissionType.Allow },
                    { Permission.FolderRename, PermissionType.Allow },
                    { Permission.FolderDelete, PermissionType.Allow },
                    { Permission.FileView, PermissionType.Allow },
                    { Permission.FileCreate, PermissionType.Allow },
                    { Permission.FileRename, PermissionType.Allow },
                    { Permission.FileDelete, PermissionType.Allow },
                    { Permission.ImageResize, PermissionType.Allow },
                    { Permission.ImageResizeCustom, PermissionType.Allow }
                }));
            });

            /*
             * Configure settings per request.
             *
             * The minimal configuration has to include at least one backend, one resource type
             * and one ACL rule.
             *
             * For example:
             * config.AddBackend("default", new LocalStorage(@"C:\files"));
             * config.AddResourceType("images", builder => builder.SetBackend("default", "images"));
             * config.AddAclRule(new AclRule(
             *     new StringMatcher("*"),
             *     new StringMatcher("*"),
             *     new StringMatcher("*"),
             *     new Dictionary<Permission, PermissionType> { { Permission.All, PermissionType.Allow } }));
             *
             * If you installed CKSource.CKFinder.Connector.Config, you may load the static configuration
             * from XML:
             * config.LoadConfig();
             *
             * If you installed CKSource.CKFinder.Connector.KeyValue.EntityFramework, you may enable caching:
             * config.SetKeyValueStoreProvider(
             *     new EntityFrameworkKeyValueStoreProvider("CKFinderCacheConnection"));
             */


            /*
             * Build the connector middleware.
             */
            var connector = connectorBuilder
                            .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to the web application pipeline.
             */
            app.UseConnector(connector);
        }