We are using SDL Tridion 2011 SP1, but with legacy VBScript templating. I want to publish some binary files to a specific folder. Can any one share the code to publish a binary using VBScript?
In the old COM API's
TCMScriptAssistant class, which has it's methods exposed to VBScript templates, there is an
AddBinary method which I think you are looking for...
Documentation is as follows:
Writes binary data from a Multimedia Component to a temporary directory so that the publisher can retrieve the file and publish it to the Content Distributor at the location specified by the Structure Group.
Use this function to publish a Binary file and obtain its URL.
Visual Basic Syntax
Public Function AddBinary( ByVal component As Variant, ByVal structureGroup As Variant, Optional ByVal variantId As String = "" ) As String
component: A Multimedia Component or URI of a Multimedia Component of which the BinaryContent is retrieved.
structureGroup: A Structure Group or URI of a Structure Group that defines the directory to which the binary will be published.
Publishing fails if a file exists in the specified location that has the same name as the file you attempt to publish, and that is not an earlier published version of this Multimedia Component.
Returns the (UTF-8) URL of the Binary file. In a UTF-8 URL, characters are first encoded in UTF-8 encoding and then standard URL encoding is applied. For example: the character
0x00B5) is first encoded in UTF-8 as two bytes:
0xB5. After URL encoding this becomes:
[% ... Dim lStrFilename lStrFilename = AddBinary(lObjMultimediaComponent, lObjStructureGroup) 'Use Filename to create image tag WriteOut "<img src=" & lstrfilename & " width=100 height=100>" %]