Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Importing images programmatically

$
0
0
I need to import a good number of images into composite. Since they all have caption info and are linked to other entities that I also need to import, I need to do this programmatically.
The below adds the image to the desired folder, but it doesn't seem to generate a GUID and it's missing its icon. What am I doing wrong?
Thanks in advance

EDIT: image.Id is read-only
            IMediaFileFolder folder = (from item in connection.Get<IMediaFileFolder>().ToList()
where item.Id == new Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
select item).Single();

            IMediaFile image = DataConnection.New<IMediaFile>();
            image.StoreId = folder.StoreId;
            image.FolderPath = folder.Path;
            image.FileName = "myphoto.jpg";
            image.Title = "A lovely photo";
            image.Description = "This is another lovely photo";
            connection.Add<IMediaFile>(image);

Viewing all articles
Browse latest Browse all 2540

Trending Articles