2

In a block of code i try to understand, a stream is published:

//Publish the stream as a binary and get the resulting URL
string replace = engine.PublishingContext.RenderedItem.AddBinary(inputStream, filename, "inline", mimetype).Url;

I noticed the stream (which is actually a xml ) is saved in the "images" folder on my server despite the fact i didn't mention anywhere the location desired for the publication.

Then, i checkedthe documentation and found this:

RenderedItem..::AddBinary Method (Stream, String, String, String)

Adds binary data as a Stream to the collection of binaries of the RenderedItem. It will be published to the context Publication images path with the specified filename. The binary can be identified by the specified variantId and is optionally related to a Component.

Thank you for your help A.

4

If you right click and select the properties of your publication, you'll see in these settings that an images path is configurable, this is typically set as 'images'

You can overload the AddBinary method to specify structure group locations where you wish to publish / store your file should, if you don't, using AddBinary will default to putting your images into the location configured in the publication.

There's quite a few overloads for AddBinary so i'd recommend having a read of this:

http://yatb.mitza.net/2012/03/which-addbinary-not-to-use.html

2

Binaries are published to a path corresponding to the "Images Path" property of the Publication where they are published from. The default value for this is "\Images"

Publication Images Path

There are also other AddBinary() methods which allow you to override this behaviour and publish a binary to a specific Structure Group, such as

RenderedItem.AddBinary(Stream, String, StructureGroup, String, String)

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.