Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Media Library Item Creation - Sitecore

RSS
Modified on Wed, Apr 04, 2012, 12:55 PM by Administrator Categorized as Sitecore
private MediaItem CreateMediaLibraryItem(Sitecore.Data.Database db, Stream sourceStream, 
    string sourceFile, string documentName, Item destFolder)
{
    var destPath = destFolder.Paths.Path + "/" + documentName;

    var options = new Sitecore.Resources.Media.MediaCreatorOptions
    {
        Database = db,
        Language = Sitecore.Globalization.Language.Current,
        Versioned = false,
        Destination = destPath,
        FileBased = true
    };

    var creator = new Sitecore.Resources.Media.MediaCreator();
    var item = creator.CreateFromStream(sourceStream, sourceFile, options);
    return item;
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.