cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco and CMIS

rahmanibilel
Champ in-the-making
Champ in-the-making
Hello, i want to read my documents from alfresco using open cmis, but i can not read from my hard disc after saving in it

my code :

Document document = documentServiceImpl.getDocumetByPath(session, "/alfresco-bpm-20090503.pdf", CMISHelper.BROWSE_OPERATION_CONTEXT) ;
InputStream stream = document.getContentStream(document.getContentStreamFileName()).getStream() ;
String path = "d:/pdf" ;
File dir = new File(path);
File file = new File(dir, "demo.pdf");
FileOutputStream out = new FileOutputStream(file) ;
byte[] bytes = new byte[stream.available()] ;
stream.read(bytes) ;
out.write(bytes) ;
out.close() ;      


help me please, thank you      
3 REPLIES 3

rahmanibilel
Champ in-the-making
Champ in-the-making
oopen cmis

kaynezhang
World-Class Innovator
World-Class Innovator
InputStream stream = document.getContentStream(document.getContentStreamFileName()).getStream() ;
is used to get a rendition stream for current document ,if you just want to get content stream for the  document,just use
InputStream stream = document.getContentStream().getStream();


Following sample code will work

         InputStream stream = document.getContentStream().getStream();
         
         String path = "d:/pdf" ;
         File dir = new File(path);
         File file = new File(dir, "demo.DOC");
         FileOutputStream out = new FileOutputStream(file) ;
         org.apache.commons.io.CopyUtils.copy(stream, out);
         out.close() ;

rahmanibilel
Champ in-the-making
Champ in-the-making
thank you very much , it works