Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

push external multimedia file in to package at tridion publish time

When we publish some page/dynamic component from tridion is it possible to add some external multimedia file/content(ex:jpg image) in to current executing/rendering package at publish time.So that final transportation package has this binary file present along with original published content? Is this achivable using customization of tridion renderer/resolver?If yes please provide some inputs.

*Note:*The binary content that needs to be pushed in to package at publish time is not present as multimedia component in tridion, it is located at other file location outside tridion CMS.Instead we have some stub multimedia component being used inside published component/page which has some dummy image. we plan to replace the stub image with original image at publish(rendering/resolving) time.

Since we have huge bulk of binary content stored in DAM tool we dont want that data to be recreated as multimedia component in tridion, insted we want to use that data by querying DAM tool and attach it in to tridion package with some logical referencesplanning to maintain one to one mapping between stub multimedia comp tcmid to original content in some mapping DB for reference).

Please let us know if any solution is there to attach external binary content to package at publish time.

like image 880
TridionDeveloper Avatar asked Sep 05 '12 15:09

TridionDeveloper


2 Answers

The best - and easiest way - is to use the mechanism provided by Tridion out-of-the-box for this. Create a new multimedia component, select "External" in the resource type drop-down, and type the URL to the object. As long as you can address it with a URL, it will work exactly as you want (item will be added to package and sent to delivery server).

If this is not good enough for you, then yes, you can add it to the package yourself. I've done this in the past with code somewhat like this:

FileInfo file = // Weird logic to get a FileInfo object from external system
Item item = package.GetItem("My original Item");
item.SetAsStream(file.OpenRead());

This replaced the content of my original component with the actual file I wanted. This will work for you IF the original component is also a multimedia component. If it's not, just create a new item with your own name, etc. If possible, do use the out-of-the-box process instead.

PS: FileInfo Class.

like image 102
Nuno Linhares Avatar answered Oct 17 '22 22:10

Nuno Linhares


As Nuno suggested the best way is to use multimedia component with 'External' resource type. You may not need to create these manually, you can automate using core services or API programs.

Another way I used before to create zip file at run time and add same to package with following code. Hope it may help.

using (MemoryStream ms = new MemoryStream())
                {
                    zip.Save(ms);
                    downloadAllInOneURL = String.Format("ZipAsset{0}.zip", uniqueZipID);
                    downloadAllInOneURL = m_Engine.PublishingContext.RenderedItem.AddBinary(ms, downloadAllInOneURL, "", "application/zip").Url;
                    downloadAllInOneSize = getSize(ms.Length);

                } 
like image 29
vikas kumar Avatar answered Oct 17 '22 21:10

vikas kumar