예제 #1
0
        private Connector GetConnector()
        {
            var driver = new AzureStorageDriver();

            string absoluteUrl = UriHelper.BuildAbsolute(Request.Scheme, Request.Host);
            var    uri         = new Uri(absoluteUrl);

            string rootDirectory = "test"; // TODO: Change this to the name of your own Azure file share.

            var root = new RootVolume(
                rootDirectory,
                $"{uri.Scheme}://{uri.Authority}/el-finder/azure-storage/files/{rootDirectory}/",
                $"{uri.Scheme}://{uri.Authority}/el-finder/azure-storage/thumb/",
                '/')
            {
                //IsReadOnly = !User.IsInRole("Administrators")
                IsReadOnly        = false,   // Can be readonly according to user's membership permission
                IsLocked          = false,   // If locked, files and directories cannot be deleted, renamed or moved
                Alias             = "Files", // Beautiful name given to the root/home folder
                MaxUploadSizeInKb = 2048,    // Limit imposed to user uploaded file <= 2048 KB
                //LockedFolders = new List<string>(new string[] { "Folder1" })
            };

            driver.AddRoot(root);

            return(new Connector(driver)
            {
                // This allows support for the "onlyMimes" option on the client.
                //MimeDetect = MimeDetectOption.Internal
            });
        }
        internal IStorageDriver Connect()
        {
            if (_storageDriver != null)
            {
                return(_storageDriver);
            }

            // If _storageDriver is null, then ConnectionString is not.

            IStorageDriver driver;

            var cname = "";
            var cs    = ConnectionString;

            var containerI = cs.IndexOf(";Container=", StringComparison.OrdinalIgnoreCase);

            if (containerI >= 0)
            {
                cname = cs.Substring(containerI + ";Container=".Length);
                cs    = cs.Substring(0, containerI);
            }

            if (cs.StartsWith("DefaultEndpointsProtocol", StringComparison.OrdinalIgnoreCase) ||
                cs.StartsWith("BlobEndpoint", StringComparison.OrdinalIgnoreCase))
            {
                var account   = CloudStorageAccount.Parse(cs);
                var client    = account.CreateCloudBlobClient();
                var container = string.IsNullOrWhiteSpace(cname)
                    ? client.GetRootContainerReference()
                    : client.GetContainerReference(cname);

                if (!client.Credentials.IsSAS)
                {
                    container.CreateIfNotExistsAsync().Wait();
                }

                driver = new AzureStorageDriver(container);
            }
            else
            {
                driver = new FileStorageDriver(cs);
            }

            if (Trace)
            {
                driver = new StatsDriverWrapper(driver);
            }

            if (ReadOnly)
            {
                driver = new ReadOnlyDriverWrapper(driver);
            }

            if (CachePath != null)
            {
                driver = new CacheStorageDriver(driver, CachePath);
            }

            return(driver);
        }
        private Connector GetConnector()
        {
            var driver = new AzureStorageDriver();

            string absoluteUrl = UriHelper.BuildAbsolute(Request.Scheme, Request.Host);
            var    uri         = new Uri(absoluteUrl);

            var root = new RootVolume(
                "test",
                $"http://{uri.Authority}/Files/",
                $"http://{uri.Authority}/el-finder/azure-storage/thumb/")
            {
                //IsReadOnly = !User.IsInRole("Administrators")
                IsReadOnly        = false,   // Can be readonly according to user's membership permission
                Alias             = "Files", // Beautiful name given to the root/home folder
                MaxUploadSizeInKb = 500,     // Limit imposed to user uploaded file <= 500 KB
                //LockedFolders = new List<string>(new string[] { "Folder1" })
            };

            driver.AddRoot(root);

            return(new Connector(driver));
        }