我正在学习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