Created
January 13, 2015 10:46
-
-
Save DominicCronin/fcc3397a21bda19f4cb8 to your computer and use it in GitHub Desktop.
Add Component Id to Binary Filename
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// componentUri is a TcmUri representing the id of the binary component that you want to publish | |
// This snippet shows how you can add the item id to the filename. | |
var component = (Component)engine.GetObject(componentUri); | |
var filename = component.BinaryContent.Filename | |
extension = Path.GetExtension(filename); | |
filename = Path.GetFileNameWithoutExtension(filename); | |
filename = String.Concat(filename, "_", componentUri.ItemId.ToString(), extension); | |
engine.AddBinary(component.Id, null, null, component.BinaryContent.GetByteArray(), filename); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment