Hopefully you can point me in the right direction with the time-pressing problem, we have a media content type, which is a meeting and has meeting date, meeting location properties etc...
After a user has created a meeting I need to create a form to allow them to go back in and upload an agenda and minutes at a later date, the agenda and minutes upload type exist in the media content.
To create a new media of type meeting I use:
MediaType mt = MediaType.GetByAlias("Meeting");
User author = User.GetUser(0);
Media EV = Media.MakeNew(ddlSelectMeeting.SelectedValue.ToString(), mt, author, 1346);
What do I use to update an existing media content type? The meeting title and meeting ID are in a drop down list which the user selects from:
Media m = new Media(1346);
foreach (Media mChild in m.Children)
{
String meetingTitle = mChild.getProperty("meetingTitle").Value.ToString();
String nodeID = mChild.Id.ToString();
ddlSelectMeeting.Items.Add(new ListItem(meetingTitle, nodeID));
}
Media can be updated as any other "content" node, just use getProperty("alias") to get the reference to the property of the media type and use .Value to get or set the value depending on selected values.
I don't really understand your SaveAs line - why are you saving into a folder named with the ID of the original media item?
My media folder is sectioned into numeric subfolders, but those folders don't bear any relation to the ids used for media files, or media folders, or anything really.
So where do they come from? Are they important, or can I just make them up and set the umbracoFile to the resulting filename?
I don't see how I can use the media ID as the folder number because there may be clashes due to the fact the folder numbers appear to generated using a completely different system.
Update media
Hi all,
Hopefully you can point me in the right direction with the time-pressing problem, we have a media content type, which is a meeting and has meeting date, meeting location properties etc...
After a user has created a meeting I need to create a form to allow them to go back in and upload an agenda and minutes at a later date, the agenda and minutes upload type exist in the media content.
To create a new media of type meeting I use:
What do I use to update an existing media content type? The meeting title and meeting ID are in a drop down list which the user selects from:
Thanks,
Media can be updated as any other "content" node, just use getProperty("alias") to get the reference to the property of the media type and use .Value to get or set the value depending on selected values.
Does that make sense?
Cheers,
/Dirk
Hi Dirk,
Apologies, I had to go off early, it was solved like this:
The important bit is the new Media, then the reference to the content node you are updating.
Thanks.
I don't really understand your SaveAs line - why are you saving into a folder named with the ID of the original media item?
My media folder is sectioned into numeric subfolders, but those folders don't bear any relation to the ids used for media files, or media folders, or anything really.
So where do they come from? Are they important, or can I just make them up and set the umbracoFile to the resulting filename?
I don't see how I can use the media ID as the folder number because there may be clashes due to the fact the folder numbers appear to generated using a completely different system.
Never, mind, found a thread that covers exactly what I want to do, no idea why it was no returned on my original Google!
http://our.umbraco.org/forum/developers/api-questions/16310-Create-new-media-using-API
is working on a reply...