Skip to main content

Posts

Showing posts from May, 2013

Create Multimedia Component using Core Service Java Client

I recently stumbled upon the following question on TREX:  http://tridion.stackexchange.com/questions/1379/not-able-to-upload-binary-images-using-core-service2011-api-from-java-client/ I had never actually attempted to upload a Binary and create a Multimedia Component using the Core Service. So I was intrigued how to achieve that. The solution is pretty straightforward, but it does contain two steps: First, upload the Binary to the TCM; Second, create the Multimedia Component referencing the path on TCM where the binary had been uploaded; The sample code below accomplishes the first step: private   static  File uploadFile(File file) {      try  {          byte [] fileData =  new   byte [( int ) file.length()];         DataInputStream dis =  new  DataInputStream( new  FileInputStream(file));         dis.readFully(fileData);         dis.close();         IStreamUpload clientUpload =                 CoreServiceFactory. getStreamUploadBasicHttpClientClient ();