Uploading Images to Folder Inside

Posted by Community Admin on 04-Aug-2018 15:32

Uploading Images to Folder Inside

All Replies

Posted by Community Admin on 23-May-2014 00:00

Hello, I am having trouble finding documentation that explains how to upload an image to an IFolder.  I have an album.  Inside this album, there is a IFolder, and inside this IFolder, there is another IFolder.

So, Album -> IFolder -> IFolder -> IMAGE_SAVE_HERE.

When saving an Image Object using the LibraryManager.Upload(Image, MemoryStream, FileExt) command, the Image object being saved must contain a valid Parent.  

Image.Parent is a Library.  Album extends Library, but IFolder does not.  So, I am unable to assign the nested IFolder I want to the Image.Parent property.

How do I go about uploading an Image to an IFolder, inside another IFolder, inside an Album?

Code Example of what I'm doing now - http://pastie.org/9202845

 

Thanks in advance for any help!

PS - When posted, I noticed that I never finished the Topic Title.  So I'm now in Edit mode of the post, but unable to edit the Topic's Title.  This should be a feature added to this forum.

Posted by Community Admin on 28-May-2014 00:00

Hello Daniel,

The easiest way to achieve this is to assign the image to an album and then relocate it to the Folder. Here is an example:

var album = librariesManager.GetAlbums().Where(i => i.Title == "TestParent").FirstOrDefault();
var childFolder = librariesManager.GetChildFolders(album).Where( c => c.Title == "ChildTest").FirstOrDefault();
 
image.Parent = album;
librariesManager.ChangeItemFolder(image, childFolder);

Documentation on managing folders can be found here.

Regards,
Ivan D. Dimitrov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed