public void Init()
        {
            rootDirectory = TestUtil.CreateTestDirectory();

            //init provider
            DownloadTransferStore = new TestTransferStore <LocalDownloadTransfer>();
            UploadTransferStore   = new TestTransferStore <LocalUploadTransfer>();

            var configuration = LocalFileSystemConfiguration.CreateForRootDirectory(rootDirectory, true);

            configuration.DownloadStore = DownloadTransferStore;
            configuration.UploadStore   = UploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;

            AdjustFileSystemConfiguration(configuration);
            FileSystemConfiguration = configuration;

            provider = new LocalFileSystemProvider(FileSystemConfiguration);
            root     = provider.GetFileSystemRoot();

            InitInternal();
        }
Example #2
0
        public void Configure()
        {
            var root     = new DirectoryInfo(@"D:\Downloads\1-Time Garbage\_VFS-SERVICE-ROOT");
            var fsConfig = LocalFileSystemConfiguration.CreateForRootDirectory(root, true);

            fsConfig.RootName = "Downloads";
            var provider = new LocalFileSystemProvider(fsConfig);

            using (OpenRastaConfiguration.Manual)
            {
                var uris = VfsUris.Default;

//        ConfigurationHelper.RegisterExceptionInterceptor();
                ConfigurationHelper.RegisterFileSystemProvider(provider);
                ConfigurationHelper.RegisterDefaultHandlers();


//        //read file as stream
//        ResourceSpace.Has.ResourcesOfType<FileDataResource>()
//          .AtUri("/files/{filepath}/data")
//          .HandledBy<DownloadHandler>();
//
//        //get download token
//        ResourceSpace.Has.ResourcesOfType<DownloadToken>()
//          .AtUri("/files/{filepath}/download/token?includefilehash={includeFileHash}")
//          .And
//          .AtUri("/files/{filepath}/download/token?includefilehash={includeFileHash}&maxblocksize={maxBlockSize}")
//          .HandledBy<DownloadHandler>()
//          .AsXmlDataContract();
            }
        }
        private void OverwriteSettings(int?providerBlockSize, int?serviceBlockSize)
        {
            //overwrite file system
            LocalFileSystemConfiguration config = LocalFileSystemConfiguration.CreateForRootDirectory(RootDirectory, true);

            config.MaxDownloadBlockSize   = providerBlockSize;
            decorator.DecoratedFileSystem = new LocalFileSystemProvider(config);

            //adjust settings
            ServiceSettings.MaxDownloadBlockSize = serviceBlockSize;
        }
        public void WhenCalling_GetLocalLibraryFolderPath_Should_ReturnLocalLibraryFolderPathFromConfiguration()
        {
            var configuration = A.Fake <IConfiguration>();

            A.CallTo(() => configuration["LocalFileSystemImageLibrary:LibraryFolderPath"])
            .Returns("C:\\LocalLibraryFolder");
            var sut    = new LocalFileSystemConfiguration(configuration);
            var result = sut.GetLocalLibraryFolderPath();

            result.Should().BeEquivalentTo("C:\\LocalLibraryFolder");
        }
Example #5
0
        public void Custom_Root_Name_Should_Be_Returned_If_Set()
        {
            var configuration = LocalFileSystemConfiguration.CreateForRootDirectory(rootDirectory, false);

            configuration.RootName = "FOO";

            provider = new LocalFileSystemProvider(configuration);
            root     = provider.GetFileSystemRoot();

            Assert.AreEqual("FOO", root.Name);
            Assert.AreEqual(rootDirectory.FullName, root.FullName);
        }
        /// <summary>
        /// Creates file system provider that is managed on the
        /// server side. This is just a <see cref="LocalFileSystemProvider"/>
        /// which manages an empty temp directory.
        /// </summary>
        /// <returns></returns>
        protected virtual IFileSystemProvider GetServiceProvider()
        {
            var root = FileUtil.CreateTempFolder("_Vfs.Restful.Server.Test");

            var configuration = LocalFileSystemConfiguration.CreateForRootDirectory(root, true);

            var downloadTransferStore = new TestTransferStore <LocalDownloadTransfer>();
            var uploadTransferStore   = new TestTransferStore <LocalUploadTransfer>();

            configuration.DownloadStore = downloadTransferStore;
            configuration.UploadStore   = uploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;
            configuration.MaxUploadFileSize           = (long)1024 * 1024 * 2048; //2GB limit

            return(new LocalFileSystemProvider(configuration));
        }
        /// <summary>
        /// Returns a file system implementation, which is assigned
        /// to the <see cref="TestContext.FileSystem"/> property.
        /// </summary>
        /// <param name="localTestFolder">The temporary test folder that is
        /// used by the context. This is actually just the <see cref="TestContext.LocalTestRoot"/>
        /// reference.</param>
        protected override IFileSystemProvider InitFileSystem(DirectoryInfo localTestFolder)
        {
            //use independent test folder
            var rootDirectory = FileUtil.CreateTempFolder("_Vfs.Local.TestRepository");

            //init provider
            var downloadTransferStore = new TestTransferStore <LocalDownloadTransfer>();
            var uploadTransferStore   = new TestTransferStore <LocalUploadTransfer>();

            var configuration = LocalFileSystemConfiguration.CreateForRootDirectory(rootDirectory, true);

            configuration.DownloadStore = downloadTransferStore;
            configuration.UploadStore   = uploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;
            configuration.MaxUploadFileSize           = (long)1024 * 1024 * 2048; //2GB limit

            return(new LocalFileSystemProvider(configuration));
        }
 /// <summary>
 /// Allows to make adjustments to the configuration that is being
 /// used to construct the provider.
 /// </summary>
 /// <param name="configuration">The preconfigured configuration.</param>
 protected virtual void AdjustFileSystemConfiguration(LocalFileSystemConfiguration configuration)
 {
 }
 /// <summary>
 /// Allows to make adjustments to the configuration that is being
 /// used to construct the provider.
 /// </summary>
 /// <param name="configuration">The preconfigured configuration.</param>
 protected virtual void AdjustFileSystemConfiguration(LocalFileSystemConfiguration configuration)
 {
 }
        public void Should_Implement_ILocalFileSystemConfiguration()
        {
            object sut = new LocalFileSystemConfiguration(A.Dummy <IConfiguration>());

            sut.Should().BeAssignableTo <ILocalFileSystemConfiguration>();
        }
        /// <summary>
        /// Initializes a new instance that provides access to the contents
        /// of a given directory.
        /// </summary>
        /// <exception cref="ArgumentNullException">If <paramref name="configuration"/>
        /// is a null reference.</exception>
        public LocalFileSystemProvider(LocalFileSystemConfiguration configuration) {
            Ensure.ArgumentNotNull(configuration, "configuration");
            FileSystemConfiguration = configuration;

            InitTransferServices();
        }