I'm trying to write a block of code to publish images uploaded in multimedia Components.
This block of code publishes only the data (4th argument) and not the image uploaded in the Component. By the way, I don't even understand why the Component (1st argument) is required because it's not used:
// Get the component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// Get the fields
ItemFields fields = new ItemFields(c.Content, c.Schema);
// get our Embedded schema field
EmbeddedSchemaField emb = (EmbeddedSchemaField)fields["Slide"];
// Loop
foreach (ItemFields embeddedfields in emb.Values)
{
foreach (ItemField field in embeddedfields)
{
ComponentLinkField fieldImage = field as ComponentLinkField;
if (fieldImage !=null)
{
Component component = fieldImage .Value;
string componentId= component.Id;
package.PushItem("ARN", package.CreateStringItem(ContentType.Text, componentId));
var sevenItems = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; // WHAT IS ACTUALLY PUBLISHED
TcmUri uri2 = new TcmUri("tcm:127-3102-4");
StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
string replace = engine.AddBinary(component.Id,null,uri2,sevenItems ,"rrrr");
}
}
}
What is the correct block of code to publish the image uploaded in the Component (1st argument)?
Is it possible to retrieve the URL of the item being published? Here, my "replace" variable contains something like this:
http://content.blabla.com/Preview/c525b64b-10ee-4587-8c30-d83865c5bdaf//rrrr
Thank you for your help