public HomeController(
     IFileSystem fileSystem,
     IFileContentTypeProvider contentTypeProvider,
     IWebHostEnvironment environment)
 {
     this.fileSystem          = fileSystem;
     this.contentTypeProvider = contentTypeProvider;
     this.fileProvider        = environment.ContentRootFileProvider;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PhysicalFileSystemEntry"/> class.
 /// </summary>
 /// <param name="fileInfo">The file info.</param>
 /// <param name="contentTypeProvider">The content type provider.</param>
 public PhysicalFileSystemEntry(
     IFileInfo fileInfo,
     IFileContentTypeProvider contentTypeProvider)
 {
     this.Name            = fileInfo.Name;
     this.ContentType     = contentTypeProvider.GetContentType(fileInfo.Name);
     this.ContentLength   = fileInfo.Length;
     this.LastModifiedUtc = fileInfo.LastModified.UtcDateTime;
     this.fileInfo        = fileInfo;
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhysicalFileSystem"/> class.
        /// </summary>
        /// <param name="options">The file system options.</param>
        /// <param name="contentTypeProvider">The content type provider.</param>
        /// <param name="environment">The host evironment.</param>
        public PhysicalFileSystem(
            IOptions <PhysicalFileSystemOptions> options,
            IFileContentTypeProvider contentTypeProvider,
            IHostEnvironment environment)
        {
            this.root = GetContentRoot(options.Value, environment.ContentRootPath);

            if (!Directory.Exists(this.root))
            {
                Directory.CreateDirectory(this.root);
            }

            this.fileProvider        = new PhysicalFileProvider(this.root);
            this.contentTypeProvider = contentTypeProvider;
        }