Hi all. I'm currently trying to make my Umbraco media use a database to populate. In order to do so I believe I need to implement IFileSystem in a custom class.
I'm hazy on how to make this work however as the exact workings of the default PhysicalFileSystem are very unclear. Could somebody give me some guidance on how to proceed?
I've looked at an Azure Blob System which does this as an example but it doesn't seem very illuminating.
If you want to implement your own, you'll need a class that inherits from IFileSystem and then you implement all the methods.
using System;
using System.Collections.Generic;
using System.IO;
using Umbraco.Core.IO;
namespace MyNamespace
{
internal class MyFileSystem : IFileSystem
{
public IEnumerable<string> GetDirectories(string path) { // implement me }
public void DeleteDirectory(string path) { // implement me }
public void DeleteDirectory(string path, bool recursive) { // implement me }
public bool DirectoryExists(string path) { // implement me }
public void AddFile(string path, Stream stream) { // implement me }
public void AddFile(string path, Stream stream, bool overrideIfExists) { // implement me }
public IEnumerable<string> GetFiles(string path) { // implement me }
public IEnumerable<string> GetFiles(string path, string filter) { // implement me }
public Stream OpenFile(string path) { // implement me }
public void DeleteFile(string path) { // implement me }
public bool FileExists(string path) { // implement me }
public string GetRelativePath(string fullPathOrUrl) { // implement me }
public string GetFullPath(string path) { // implement me }
public string GetUrl(string path) { // implement me }
public DateTimeOffset GetLastModified(string path) { // implement me }
public DateTimeOffset GetCreated(string path) { // implement me }
}
}
Thanks for the info. I realized after quite a bit of slogging that my issue was with the FileSystemProvider.config file. I hadn't realized that the second entry of the <Provider> tag referred to the assembly for the custom class which inherited from IFileSystem I made to replace PhysicalFileSystem.
Overriding IFileSystem
Hi all. I'm currently trying to make my Umbraco media use a database to populate. In order to do so I believe I need to implement
IFileSystem
in a custom class.I'm hazy on how to make this work however as the exact workings of the default
PhysicalFileSystem
are very unclear. Could somebody give me some guidance on how to proceed?I've looked at an Azure Blob System which does this as an example but it doesn't seem very illuminating.
This is how
PhysicalFileSystem
works, exactly:https://github.com/umbraco/Umbraco-CMS/blob/75c2b07ad3a093b5b65b6ebd45697687c062f62a/src/Umbraco.Core/IO/PhysicalFileSystem.cs
If you want to implement your own, you'll need a class that inherits from
IFileSystem
and then you implement all the methods.Thanks for the info. I realized after quite a bit of slogging that my issue was with the
FileSystemProvider.config
file. I hadn't realized that the second entry of the<Provider>
tag referred to the assembly for the custom class which inherited fromIFileSystem
I made to replacePhysicalFileSystem
.Inserting that assembly got Umbraco to use my custom class.
is working on a reply...