這裏我附上的實現方法:
String attachmentPath = null;
if (!ioFiles.isEmpty()) {
Session adminSession = NuxeoUtil.getNuxeoAdminSession();
Document collectionDoc = null;
try {
collectionDoc = (Document) adminSession.newRequest(DocumentService.FetchDocument)
.set(NuxeoConstants.NUXEO_VALUE, originalCollectionId).execute();
DocumentService rs = adminSession.getAdapter(DocumentService.class);
DocRef docRef = new DocRef(originalCollectionId);
attachmentPath = collectionDoc.getPath();
if (docRef != null) {
for (File file : ioFiles) {
Blob blob = new FileBlob(file);
rs.setBlob(docRef, blob, "files:files");
}
}
NuxeoUtil.closeNuxeoSession(adminSession);
} catch (Exception e) {
_log.error(e);
}
}
感謝Blowder先生。它爲我工作。 –