I am creating a member profile page where they can upload an image to go along with their details - basically an avatar I guess, but can be quite large as is not used exactly like an avatar.
Is there a control available in any of the Umbraco assemblies I can just drop in that basically does what the ASP.NET file upload does except it saves everything to the media library and gives me the ID back?
I presume the uploadField datatype must do something like that, but I can't find just a Control I can drop in.
That would be a perfectly acceptable substitute if there is no preexisting control, can you point me to some examples / documentation? Or even just the assembly / namespace / class to look at.
I don't want to wade through the source particularly, if I can do it by looking at the metadata from the assemblies I would prefer that, just need to know where to start looking.
Here's a link to using the document api, which is quite similar to the media api (can't find any docs on media api atm)... references in the using section should get you to the Media class as well
One final question however - it's all working perfectly now, uploading the image, I am settign width / height, everythign groovy - however, it doesn't in the Contents of the parent folder - should it? If so, how does one go about that?
Wow, you're right, that makes no sense whatsoever, looks like I was having some kind of seizure :o) Let's try again.
In the Media section, when you click on a folder, you get the Contents tab, containing a Contents control with thumbnails of all the images in the folder. I assumed that was generated automatically by whatever was in the folder, but when I upload stuff using the API, although it is all in the library fine and can be used, it does not appear in the Contents control of the parent folder.
Guess that's because you're using the Media api, which may not create the thumbnails... Probably the only solution to have those thumbnails (if you must), is to create those yourself... shouldn't be too difficult (you can use the umbraco source for the upload editor control)
Aha! So it uses pre-created thumbnails rather than just thumbnailing on the fly. I don't particularly care about that right now so I think I'll leave it. Thanks for you help!
Uploading files to umbraco from outside admin
I am creating a member profile page where they can upload an image to go along with their details - basically an avatar I guess, but can be quite large as is not used exactly like an avatar.
Is there a control available in any of the Umbraco assemblies I can just drop in that basically does what the ASP.NET file upload does except it saves everything to the media library and gives me the ID back?
I presume the uploadField datatype must do something like that, but I can't find just a Control I can drop in.
can't you just go with a standard asp.net upload control and create media item using the media api?
Cheers,
/Dirk
That would be a perfectly acceptable substitute if there is no preexisting control, can you point me to some examples / documentation? Or even just the assembly / namespace / class to look at.
I don't want to wade through the source particularly, if I can do it by looking at the metadata from the assemblies I would prefer that, just need to know where to start looking.
Here's a link to using the document api, which is quite similar to the media api (can't find any docs on media api atm)... references in the using section should get you to the Media class as well
http://our.umbraco.org/wiki/reference/api-cheatsheet/creating-a-document
Cheers,
/Dirk
Aha, found this other thread - that you answered, in fact! :o)
http://our.umbraco.org/forum/developers/api-questions/7962-Update-media
For anyone else finding this thread, the assembly is "cms.dll", and the namespace is "umbraco.cms.businesslogic.media"
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
Thanks for your help, Dirk.
One final question however - it's all working perfectly now, uploading the image, I am settign width / height, everythign groovy - however, it doesn't in the Contents of the parent folder - should it? If so, how does one go about that?
Hmm, not sure what you mean? seems some words have fallen off?
/Dirk
Wow, you're right, that makes no sense whatsoever, looks like I was having some kind of seizure :o) Let's try again.
In the Media section, when you click on a folder, you get the Contents tab, containing a Contents control with thumbnails of all the images in the folder. I assumed that was generated automatically by whatever was in the folder, but when I upload stuff using the API, although it is all in the library fine and can be used, it does not appear in the Contents control of the parent folder.
Rob,
Guess that's because you're using the Media api, which may not create the thumbnails... Probably the only solution to have those thumbnails (if you must), is to create those yourself... shouldn't be too difficult (you can use the umbraco source for the upload editor control)
Cheers,
/Dirk
Aha! So it uses pre-created thumbnails rather than just thumbnailing on the fly. I don't particularly care about that right now so I think I'll leave it. Thanks for you help!
Yup, as soon as you upload through the media section, thumbnails are created based on configuration in umbracoSettings.config.
Cheers,
/Dirk
is working on a reply...