I seem to be having a bit of trouble with binary components getting corrupted on publish.
I'm using the following code to publish the binary:
var img = (Component)Engine.GetObject(binaryWebdav);
var binaryPublishPath = Engine.AddBinary(img.Id,
template.Id,
structureGroup.Id,
img.BinaryContent.GetByteArray(),
filename);
This all works; but, the published file has different binary data then the file that has originally uploaded to Tridion as shown in the Hex comparison below.
Downloading the file straight out of Tridion results in no problems so definitely something to do with the publishing.
The site is current set to publish out as UTF8 so can only think that this has something to do with it.
The storage config is pretty standard with the following:
<Storages>
....
<Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory"
Id="defaultFile" defaultFilesystem="false">
<Root Path="C:\inetpub\wwwroot" />
</Storage>
<Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory"
Id="defaultDataFile" defaultFilesystem="true" defaultStorage="true">
<Root Path="C:\inetpub\wwwroot\data" />
</Storage>
</Storages>
...
<Item typeMapping="Binary" itemExtension=".eot" storageId="defaultFile" cached="true"/>
...
Is there a way to disregard the encoding? Is it even the encoding that is causing this?
The files need to match as there is a problem with eot fonts unless the file matches exactly as it was before being added to Tridion.
Engine.PublishingContext.RenderedItem.AddBinary(stream, filename, variantId, img, img.BinaryContent.MultimediaType.MimeType)
instead? You can get the stream viaimg.BinaryContent.WriteToStream(stream)
.