public FileSystemStorageProviderTests()
        {
            _fixture = new Fixture();

            var mockFileConfiguration = new Mock <IOptions <FileSystemStorageProviderConfiguration> >();
            var mockOptions           = new Mock <FileSystemStorageProviderConfiguration>();

            mockFileConfiguration.Setup(x => x.Value).Returns(mockOptions.Object);

            var mockLogger = new Mock <ILogger <FileSystemStorageProvider> >();

            _fileSystemStorageProvider = new FileSystemStorageProvider(mockFileConfiguration.Object, mockLogger.Object);
        }
        public void Init()
        {
            _folderPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Media"), "Default");
            _filePath   = _folderPath + "\\testfile.txt";

            Directory.CreateDirectory(_folderPath);
            File.WriteAllText(_filePath, "testfile contents");

            var subfolder1 = Path.Combine(_folderPath, "Subfolder1");

            Directory.CreateDirectory(subfolder1);
            File.WriteAllText(Path.Combine(subfolder1, "one.txt"), "one contents");
            File.WriteAllText(Path.Combine(subfolder1, "two.txt"), "two contents");

            var subsubfolder1 = Path.Combine(subfolder1, "SubSubfolder1");

            Directory.CreateDirectory(subsubfolder1);

            _storageProvider = new FileSystemStorageProvider(new FileSystemSettings {
                DirectoryName = "Default"
            });
        }
Пример #3
0
 public void CopyFile(string originalPath, string duplicatePath)
 {
     FileSystemStorageProvider.CopyFile(originalPath, duplicatePath);
 }
Пример #4
0
 public string GetStoragePath(string url)
 {
     return(FileSystemStorageProvider.GetStoragePath(url));
 }
Пример #5
0
 public string Combine(string path1, string path2)
 {
     return(FileSystemStorageProvider.Combine(path1, path2));
 }
Пример #6
0
 public string GetPublicUrl(string path)
 {
     return(FileSystemStorageProvider.GetPublicUrl(path));
 }
Пример #7
0
 public StubStorageProvider(ShellSettings settings)
 {
     FileSystemStorageProvider = new FileSystemStorageProvider(settings);
     SavedStreams = new List <string>();
     CreatedFiles = new List <string>();
 }
Пример #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //register FEConsole Services.
            services.AddSingleton <IFileStorageService>(provider =>
            {
                string configuredPath    = Configuration["SiteSettings:FileStoreProviders:FileSystem:RootDir"];
                DirectoryInfo directory  = new DirectoryInfo(configuredPath);
                string rootFileDirectory = directory.FullName.Equals(configuredPath, StringComparison.InvariantCultureIgnoreCase)
                        ? configuredPath :
                                           Path.Combine(Environment.CurrentDirectory, configuredPath);
                var fileProvider = new FileSystemStorageProvider(rootFileDirectory);

                string widthConfig = Configuration["SiteSettings:FileStorageService:Thumbinal:Width"] ?? "260";
                string heighConfig = Configuration["SiteSettings:FileStorageService:Thumbinal:Height"] ?? "260";
                ThumbinalConfig thumbinalConfig = new ThumbinalConfig()
                {
                    Width  = int.Parse(widthConfig),
                    Height = int.Parse(heighConfig)
                };

                var resxFileProvider   = new EmbededResourceStorageProvider();
                var fileStorageService = new DefaultFileStorageService(fileProvider,
                                                                       thumbinalConfig);
                fileStorageService.AddStorageProvider(resxFileProvider);

                return(fileStorageService);
            });
            services.AddSingleton <IObjectService>(new DefaultObjectService());
            services.AddSingleton <IRSACryptographyService>(CryptographyServiceFactory.RSACryptoService);
            services.AddSingleton <ISymmetricCryptographyService>(CryptographyServiceFactory.SymmetricCryptoService);
            services.AddSingleton <ISHAService>(CryptographyServiceFactory.SHAService);

            services.AddCors(options =>
            {
                List <string> cors = new List <string>();
                Configuration.Bind("SiteSettings:CORS", cors);
                options.AddPolicy(name: FEAPIAllowSpecificOrigins,
                                  builder =>
                {
                    builder
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .WithOrigins(cors.ToArray());
                });
            });

            if (reverseProxyConfig?.Enabled == true)
            {
                services.Configure <ForwardedHeadersOptions>(options =>
                {
                    foreach (var ip in reverseProxyConfig.AllowedIPAddress)
                    {
                        options.KnownProxies.Add(IPAddress.Parse(ip));
                    }
                });
            }


            services.AddAuthentication("Bearer")
            .AddJwtBearer("Bearer", options =>
            {
                options.Authority = Configuration.GetSection("Authentication:IdentityServer")
                                    .GetValue <string>("Url");
                options.RequireHttpsMetadata = Configuration.GetSection("Authentication:IdentityServer")
                                               .GetValue <bool>("RequireHttpsMetadata");

                options.Audience = "feconsoleapi";
            });

            //memory cache.
            services.AddMemoryCache();

            services.AddControllers(options => {
                options.InputFormatters.Insert(0, new ObjectDefintionFormatter());
            })
            .AddNewtonsoftJson(options => {
                options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                options.SerializerSettings.Formatting       = Newtonsoft.Json.Formatting.Indented;
                //options.SerializerSettings.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.Objects;
                //options.SerializerSettings.Converters.Add()
            });

            services.AddSwaggerDocument(swgOptions => {
                swgOptions.PostProcess = document =>
                {
                    document.Info.Version        = "v1";
                    document.Info.Title          = "FEConsole API";
                    document.Info.Description    = "API of the FEConsole Application.";
                    document.Info.TermsOfService = "None";
                    document.Info.Contact        = new NSwag.OpenApiContact
                    {
                        Name  = "FETECHLAB",
                        Email = string.Empty,
                        Url   = "https://fetechlab.com/"
                    };
                    document.Info.License = new NSwag.OpenApiLicense
                    {
                        Name = "License",
                        Url  = "https://www.apache.org/licenses/LICENSE-2.0"
                    };
                };
            });
        }
 private FileSystemStorageProvider GetProvider(string basePath) {            
     var provider = new FileSystemStorageProvider(() => this.mockFileSystem);
     
     return provider;
 }
        private FileSystemStorageProvider GetProvider(string basePath)
        {
            var provider = new FileSystemStorageProvider(() => this.mockFileSystem);

            return(provider);
        }
 public static IFileCabinetFactory RegisterFileSystemProvider(this IFileCabinetFactory factory) {
     var provider = new FileSystemStorageProvider(fileSystemFactory: () => new System.IO.Abstractions.FileSystem());
     factory.RegisterProvider(provider);
     return factory;
 }