我正在學習CMIS並遇到類似於以下的代碼,它使用CMIS創建文檔。我想使用CMIS的createDocument方法來上傳存儲在本地機器文件夾中的文件。我怎樣才能做到這一點?如何使用CMIS上傳文檔?
Folder parent = ....
String name = "myNewDocument.txt";
// properties
// (minimal set: name and object type id)
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.NAME, name);
// content
byte[] content = "Hello World!".getBytes();
InputStream stream = new ByteArrayInputStream(content);
ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(content.length), "text/plain", stream);
// create a major version
Document newDoc = parent.createDocument(properties, contentStream, VersioningState.MAJOR);
「FileInputStream」有什麼問題? – Gagravarr