Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaFileSystem"/> class.
 /// </summary>
 public MediaFileSystem(IFileSystem innerFileSystem, IContentSection contentConfig, IMediaPathScheme mediaPathScheme, ILogger logger)
     : base(innerFileSystem)
 {
     _contentConfig   = contentConfig;
     _mediaPathScheme = mediaPathScheme;
     _logger          = logger;
 }
Пример #2
0
 public MediaFileManager(
     IFileSystem fileSystem,
     IMediaPathScheme mediaPathScheme,
     ILogger <MediaFileManager> logger,
     IShortStringHelper shortStringHelper,
     IServiceProvider serviceProvider,
     IOptions <ContentSettings> contentSettings)
     : this(fileSystem, mediaPathScheme, logger, shortStringHelper, serviceProvider)
 {
 }
Пример #3
0
 public MediaFileManager(
     IFileSystem fileSystem,
     IMediaPathScheme mediaPathScheme,
     ILogger <MediaFileManager> logger,
     IShortStringHelper shortStringHelper,
     IServiceProvider serviceProvider)
 {
     _mediaPathScheme   = mediaPathScheme;
     _logger            = logger;
     _shortStringHelper = shortStringHelper;
     _serviceProvider   = serviceProvider;
     FileSystem         = fileSystem;
 }
Пример #4
0
 public MediaFileManager(
     IFileSystem fileSystem,
     IMediaPathScheme mediaPathScheme,
     ILogger <MediaFileManager> logger,
     IShortStringHelper shortStringHelper,
     IServiceProvider serviceProvider,
     IOptions <ContentSettings> contentSettings)
 {
     _mediaPathScheme   = mediaPathScheme;
     _logger            = logger;
     _shortStringHelper = shortStringHelper;
     _serviceProvider   = serviceProvider;
     _contentSettings   = contentSettings.Value;
     FileSystem         = fileSystem;
 }
Пример #5
0
        public void Can_Delete_MediaFiles()
        {
            MediaFileManager mediaFileManager = GetRequiredService <MediaFileManager>();
            var    memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("test"));
            string virtualPath  = mediaFileManager.GetMediaPath("file.txt", Guid.NewGuid(), Guid.NewGuid());

            mediaFileManager.FileSystem.AddFile(virtualPath, memoryStream);

            // ~/media/1234/file.txt exists
            IHostingEnvironment hostingEnvironment = GetRequiredService <IHostingEnvironment>();
            string physPath = hostingEnvironment.MapPathWebRoot(Path.Combine("media", virtualPath));

            Assert.IsTrue(File.Exists(physPath));

            // ~/media/1234/file.txt is gone
            mediaFileManager.DeleteMediaFiles(new[] { virtualPath });
            Assert.IsFalse(File.Exists(physPath));

            IMediaPathScheme scheme = GetRequiredService <IMediaPathScheme>();

            if (scheme is UniqueMediaPathScheme)
            {
                // ~/media/1234 is *not* gone
                physPath = Path.GetDirectoryName(physPath);
                Assert.IsTrue(Directory.Exists(physPath));
            }
            else
            {
                // ~/media/1234 is gone
                physPath = Path.GetDirectoryName(physPath);
                Assert.IsFalse(Directory.Exists(physPath));
            }

            // ~/media exists
            physPath = Path.GetDirectoryName(physPath);
            Assert.IsTrue(Directory.Exists(physPath));
        }
Пример #6
0
 public ImageFilterBackofficeApiController(IMediaPathScheme mediaPathScheme)
 {
     _mediaPathScheme = mediaPathScheme;
 }