-2

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?

3

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:

AddBinary

Summary

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.

Usage

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

Parameters

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.

Remarks

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.

Return value

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 µ (Unicode: 0x00B5) is first encoded in UTF-8 as two bytes: 0xC2 and 0xB5. After URL encoding this becomes: %C2%B5.

Example

[% 
... 
Dim lStrFilename 

lStrFilename = AddBinary(lObjMultimediaComponent, lObjStructureGroup) 

'Use Filename to create image tag 
WriteOut "<img src=" & lstrfilename & " width=100 height=100>" 
%]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.