I was looking for an example about this, and found your question,
the problem with the original if I am not mistaken is that you are
reading the buffer beforehand so the pointer is at the end of it when
you pass it to the content stream, I am making a little class just to test
some functionality I want to implement in a program later and this block
works with your initial approach.
File content = new File("C:\\\\asdf.asdf");
try{
String mimeType = new MimetypesFileTypeMap().getContentType(content);
System.out.println("mimetype: " + mimeType);
System.out.println("file: " + content.getAbsolutePath());
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID,BaseTypeId.CMIS_DOCUMENT.value()+",P:cm:titled");
properties.put("cm:description", "upload desde código");
properties.put(PropertyIds.NAME, content.getName());
FileInputStream fis = new FileInputStream(content);
DataInputStream dis = new DataInputStream(fis);
ContentStream cs = new ContentStreamImpl(content.getName(),BigInteger.valueOf(content.length()), mimeType, dis);
Document doc = newFolder.createDocument(properties, cs, VersioningState.MAJOR);
}catch(CmisBaseException ex){
Logger.getLogger(CMISTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (FileNotFoundException ex) {
Logger.getLogger(CMISTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(CMISTest.class.getName()).log(Level.SEVERE, null, ex);
}