-2

I am trying to find the code in java API which works with cm IBM.. the sample code is there but it is just for logging in.. can anyone help to get the code to download the images along with metadata

Rajat
  • 31
  • 1
  • 6

1 Answers1

0

as you said you have basic connection code, use the below function to download the document..

 public String retrieveDocument(CMBConnection connection, CMBItem item)
          throws CMBException, IOException, Exception 
     {
          // Get an instance of data management bean
          CMBDataManagement dataManagement = connection.getDataManagement();
          // Set the current data item
          dataManagement.setDataObject(item);
          // Retrieve the original file name
          CMBObject object = dataManagement.getContent(0);
          String inputFileName = object.getOriginalFileName();
          // Parse the file name from the full path
          int pos=inputFileName.lastIndexOf("\\");
          inputFileName = inputFileName.substring(pos+1);
          // Write the document content to a new file 
          String fileName = System.getProperty("user.dir") 
               + File.separator + inputFileName;
          System.out.println("Output file name " + fileName); 
          FileOutputStream fileoutstream = new FileOutputStream(fileName);
          fileoutstream.write(dataManagement.getContent(0).getData());
          fileoutstream.close();
          // Return file name
          return fileName;
     }
Krunal Barot
  • 914
  • 6
  • 17