To use the extenal url for the blob you could either redirect incoming requests to the external url or change the generated url for your blob to be to the external url. For both cacse could you use an eventhandler on IContentRouteEvents, either to event CreatedVirtualPath if you prefer to change the outgoing url or to RoutedContent if you prefer to redirect the incoming request.
See e.g. https://world.episerver.com/blogs/K-Khan-/Dates/2014/12/using-blobs-and-cdn-both-effectively/
Thanks for your reply Johan, this looks like exactly what I need. Where exactly is this logic supposed to be implemented? In the class that inherits `ContentProvider`?
You can get the instance of IContentRouteEvents from the IOC container then you can hook up an event handler to either VirtualPathCreated or ContentRouted event (depending on if you want to change outgoing urls or redirect incoming urls).
So the logic would be in the event handler. You can look at the previously linked blog post to get some inspiration.
Johan,
I am working on this same issue with Michelangelo. Our problem is that our image, from our custom content provider, never appears in CreatedVirtualPath.
In CreatingVirtualPath, if we extract {node} from eventArgs.RouteValues, we can see the ID of our custom content provider image.
But in CreatedVirtualPath, if we extract {node} from eventArgs.RouteValues, we never see the ID of our image. That is, the CreatedVirtualPath event is never raised for our image.
So, somewhere between CreatingVirtualPath and CreatedVirtualPath, the CMS is abandoning our image.
Can you think of any reason why it might be doing that?
We tried adding MVC routes to the RouteTable, and adding a partial router, but that didn't seem to help (nor did I expect it to).
Thank you for taking the time to look at this for us!
Does the link get generated to a friendly format? (that is a hiearchical url and not a guid based internal format).
The content route will only raise the CreatedVirtualPath in case it could resolve a url for the node.
Where would the link be "generated"? My limited understanding was that we were "generating" the URL while overriding these event handlers. We do not set any url/blob data in our actual contnet provider.
Johan,
I was finally able to get this working using the content provider and a partial router alone. In GetVirtualPath, we were able to set the CDN URL via returning partial route data, but were setting the base path to null. I changed it to ContentReference.RootPage and it worked.
I can follow up with some sample code for anyone else who stumbles on this problem. There is some extra plumbing you have to do to get the thumbnail working in CMS Edit. Ultimately we are skipping blobs entirely and using CDN URLs with an ImageData content type strictly for the content editor's benefit.
Thanks for your help
I am trying to implement a custom content provider in Epi CMS. Its basically just an image provider, but using a 3rd party image host. So the content provider I am developing should not be loading in binary/blob data to Epi and instead just use the Url of the 3rd party hosted image as the Url Epi uses to display the image. Everything I am finding online, in World and in various Github repos use blob data, or the content is blocks and not images so I am having a heck of a time. Has anyone implemented anything similar?