Uploading Images to Folder Inside
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.
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);