There are other resources and examples around which, with a little imagination, should get you where you want to be :)
If you're lucky enough to be importing into known Media folders, I'd stream the media in, save it, inspect the relevant Media folder for mediaItem ID's, then save the list to use in a ContentItem's mediaPicker (which just requires a comma separated list of ID's). You create the ContentItem right there.
Thanks, I can see how those events can be used to programmatically deal with content and media items.
Forgive my ignorance though... Where and how do I tie into these? Can I use a datatype/macro/contentType in the backend to run custom code?
I remember in a previous version of Umbraco, there was a site template you could install where media uploads had a checkbox that said something like "auto-create matching content"... That's what I'm trying to duplicate.
Create matching content when you upload media
In the backend, is there a way to programmatically / automatically create content nodes when you upload media?
Basically I would like to auto-create a bunch of blog post content nodes (with matching titles), when I upload media.
Has anyone tried to program something like this for the back end?
Hi Chris,
I did something recently using the ContentService and MediaService to import content and related media. See them both here for starters: https://our.umbraco.com/Documentation/Reference/Management/Services/
Then: https://our.umbraco.com/documentation/reference/events/contentservice-events
and
https://our.umbraco.com/documentation/reference/events/mediaservice-events
and
http://jamessouth.me/archive/experiments-with-umbracos-icontentservice/
There are other resources and examples around which, with a little imagination, should get you where you want to be :)
If you're lucky enough to be importing into known Media folders, I'd stream the media in, save it, inspect the relevant Media folder for mediaItem ID's, then save the list to use in a ContentItem's mediaPicker (which just requires a comma separated list of ID's). You create the ContentItem right there.
Hope this helps.
Craig
Thanks, I can see how those events can be used to programmatically deal with content and media items.
Forgive my ignorance though... Where and how do I tie into these? Can I use a datatype/macro/contentType in the backend to run custom code?
I remember in a previous version of Umbraco, there was a site template you could install where media uploads had a checkbox that said something like "auto-create matching content"... That's what I'm trying to duplicate.
Hi Chris,
To hook into the events, you'd need to implement a class that inherits from Application Startup class.
https://our.umbraco.com/documentation/Reference/Events/Application-Startup
In here you can access the media and content services and attach to the events which means you can then do what you need.
Nik
is working on a reply...