FileUpload DataType - How does it save media with IFileSystem Providers
Hello all,
I am trying to get my head around the source code in Umbraco and wondered if any of you smart guys are able to give me advice please.
I want to use the IFileSystem provider that Dirk S has created for Azure Blob Storage and save other files in the media section that do not use the file upload datatype, but however pragmatically save the file via the custom File System provider to ensure the saved file also gets put into Azure blob storage.
So for me to try & understand this I was trying to pull apart the source code in Umbraco to understand this, but I seem to be going down a rabbit hole and getting slightly lost on where to look.
Should I be looking in the MediaService or should I be using something else to save files via the FileSystem provider in place.
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
//Line 81 of FileUploadPropertyValueEditor.cs
fs.DeleteFile(fs.GetRelativePath(toRemove), true);
//Line 129 of FileUploadPropertyValueEditor.cs
var umbracoFile = UmbracoMediaFile.Save(fileStream, fileName);
//Method in UmbracoMediaFile.cs
public static UmbracoMediaFile Save(Stream inputStream, string path)
{
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
fs.AddFile(path, inputStream);
return new UmbracoMediaFile(path);
}
But the magic seems to be in the class FileSystemWrapper.cs with methods like so:
FileUpload DataType - How does it save media with IFileSystem Providers
Hello all,
I am trying to get my head around the source code in Umbraco and wondered if any of you smart guys are able to give me advice please.
I want to use the IFileSystem provider that Dirk S has created for Azure Blob Storage and save other files in the media section that do not use the file upload datatype, but however pragmatically save the file via the custom File System provider to ensure the saved file also gets put into Azure blob storage.
So for me to try & understand this I was trying to pull apart the source code in Umbraco to understand this, but I seem to be going down a rabbit hole and getting slightly lost on where to look.
Should I be looking in the MediaService or should I be using something else to save files via the FileSystem provider in place.
Many Thanks,
Warren
Isn't this "just" handled by the provider and the Content/MediaService where you store the file using a stream?
Hi RIchard,
I am not 100% sure about that.
Here are some snippets/findings I have found:
But the magic seems to be in the class FileSystemWrapper.cs with methods like so:
Example comes from the "official" documentation http://our.umbraco.org/documentation/Reference/Management-v6/Models/Content
CMSImport V3 is using that as well. I think that method talks to the underlying Filesystemprovider used in filesystem code you found.
is working on a reply...