コアサービスを使用して、PDF、Word、およびExcelファイルをSDL Tridion 2011にプッシュしたいとします。コアサービスを使用して外部ファイルをSDL Tridion 2011にインポートするにはどうすればよいですか?
私はコードの下にしようとしたが、このエラーを取得:
Invalid value for property 'BinaryContent'. Unable to open uploaded file:
using (ChannelFactory<ISessionAwareCoreService> factory =
new ChannelFactory<ISessionAwareCoreService>("wsHttp_2011"))
{
ISessionAwareCoreService client = factory.CreateChannel();
ComponentData multimediaComponent = (ComponentData)client.GetDefaultData(
ItemType.Component, "tcm:19-483-2");
multimediaComponent.Title = "MultimediaFile";
multimediaComponent.ComponentType = ComponentType.Multimedia;
multimediaComponent.Schema.IdRef = "tcm:19-2327-8";
using (StreamUploadClient streamClient = new StreamUploadClient())
{
FileStream objfilestream = new FileStream(@"\My Documents\My Poc\images.jpg",
FileMode.Open, FileAccess.Read);
string tempLocation = streamClient.UploadBinaryContent("images.jpg",
objfilestream);
}
BinaryContentData binaryContent = new BinaryContentData();
binaryContent.UploadFromFile = @"C:\Documents and Settings\My Poc\images.jpg";
binaryContent.Filename = "images.jpg";
binaryContent.MultimediaType = new LinkToMultimediaTypeData()
{
IdRef ="tcm:0-2-65544"
};
multimediaComponent.BinaryContent = binaryContent;
IdentifiableObjectData savedComponent = client.Save(multimediaComponent,
new ReadOptions());
client.CheckIn(savedComponent.Id, null);
Response.Write(savedComponent.Id);
}
@ Chris。私はそのコードを試しましたが、エラーが発生しました。 binaryContent.MultimediaType = new LinkToMultimediaTypeData(){IdRef = id};私はjpgファイルをしようとすると、私はこのIDを取得する方法を知らせることができますか? プロジェクトにはapp.configはありません ありがとうございます – Aquarius24
質問を更新して、あなたのコードを表示し、受け取ったエラーを共有することができます。 もう1つの注意点 - http://area51.stackexchange.com/proposals/38335/tridion?referrer=eo63snjNlUWNn9xqeeO2NA2へのコミットを検討しますか?スタックエクスチェンジで専用のSDL Tridion領域を取得しようとしています。あなたのSOアカウントを使用してください。ここで大きな質問は、 –
というエラーになります。 プロパティ 'BinaryContent'の値が無効です。アップロードしたファイルを開くことができません – Aquarius24