Using CMSDesk and click on the Tools tab, then Media Library I can add files to the inbuilt Kentico Media Library. Is there a way to do this using their API?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
You can do this using the Kentico API. It is actually quite rich but the documentation and samples out there are a bit lacking.
Following is a sample method (actually used as a web service method as we have both remote and local pages that use it) and a sample method that calls it (say from an 'edit' web page).
fileLogo - > protected System.Web.UI.WebControls.FileUpload fileLogo;
Keeping it here as the original link seems to be dead.
Posted on June 23, 2010 by kevin
So, if you’ve ever worked with the .NET based CMS Kentico (http://www.kentico.com), you’ll know that Media Libraries can be a very powerful tool for organizing your non-site data, including images, documents, and anything else that you need storing and integrating with your CMS. And it all works fantastically, as long as you don’t try to do anything with it code-side. That’s where things get interesting, to say the least.
The Kentico documentation website (http://devnet.kentico.com/documentation.aspx) is very useful in terms of working with and manipulating the tree from the code, it offers very little in terms of manipulating and working-with in general with Media Libraries. So I spent a good amount of time looking through the Modules seeing what Kentico does and how it does it so you don’t have to.
Since this is my first post, and I’m still a little rusty on the whole “writing” thing, so let’s just get to the code.
I think this is pretty self explanatory, we create a MediaFileInfo object, set some stuff in it, and then insert it into the MediaFileInfoProvider. There are a lot of additional properties within the MediaFileInfo object, such as FileSize, which (as the name of the property suggests), stores the file size in a long. Pro tip – use the
CMS.GlobalHelper.DataHelper.GetSizeString
function to convert the long to a string, formatting it into user-readable data.This really just scratches the surface on what you can do with Media Libraries in the code-behind. Take a closer look at the
MediaFileInfo
andMediaFIleInfoProvider
classes, along with theMediaLibraryHelper
,MediaLibraryInfo
,MediaLibraryInfoProvider
classes. There’s very little that can’t be done.this seems to do what you want http://www.rustedmushroom.com/2010/06/working-with-media-libraries-in-kentico-undocumented-api-style/
[EDIT: As of 4/4/2013, this link above is dead. If someone finds an alternate link, please update and remove this message.]