I've been trying to change Umbraco so the media is provided via Cloudinary.
What I have done so far is make a new IFileSystem
Here's a small snippet:
public CloudinaryFileSystem()
{
var account = new Account(
"account",
"key",
"secret");
_cloudinary = new CloudinaryDotNet.Cloudinary(account);
}
public IEnumerable<string> GetDirectories(string path)
{
var test = "test";
return new List<string>{test};
}
I've also updated the FileSystemProvider.config:
<!-- Media -->
<Provider alias="media" type=" Extensions.CloudinaryFileSystem, Extensions">
<Parameters>
</Parameters>
</Provider>
I've also added the media path location in the web.config:
<location path="media">
<system.webServer>
<handlers>
<remove name="StaticFileHandler" />
<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
</handlers>
</system.webServer>
</location>
Now when I run the project I can upload a new image:
When I upload an image it hits my custom file provider and uploads the file to Cloudinary
Code:
public void AddFile(string path, Stream stream)
{
ImageUploadParams prmas = new ImageUploadParams();
var folder = path.Split('\\')[0];
var name = path.Split('\\')[1];
prmas.Folder = "media/" + folder;
prmas.UseFilename = true;
prmas.File = new FileDescription(name, stream);
_cloudinary.Upload(prmas);
}
The issue I have now is that when looking at the media in Umbraco it still comes from the local media, I have all the methods implemented for IFileSystem but only a could of them are hit when I browser the media in Umbraco.
At the moment I'm just playing around so the code is a bit dirty. But I can't see why it's not working.
Am I missing something?
Thanks!
