简体   繁体   中英

How to get the Name, MIME Type and Content of a VWAttachment in Filenet P8?

I have been trying to get the name, MIME type and content of a VWAttachment in FileNet P8. The content should be a byte array or an input stream.

UPDATE:

String name = attachment.getAttachmentName();

Gives me the name of VWAttachment . And let's say by looking at the file extension I can decide proper MIME type. I need to know how can I get the content of the attachment in an InputStream

Any help is appreciated. Thanks!

You need to use the information in the VWAttachment object to fetch the correct document from the Content Engine.

for example:

com.filenet.api.core.Domain domain = (...you need to get this);
VWAttachment vwAttachment = (...you already have this);

ObjectStore objectStore = Factory.ObjectStore.getInstance(domain, vwAttachment.getLibraryName());
VersionSeries vs = Factory.VersionSeries.fetchInstance(objectStore, new Id( vwAttachment.getId()), null);
Document document = (Document) vs.get_CurrentVersion();

ContentTransfer contentTransfer = (ContentTransfer) document.get_ContentElements().get(0);
InputStream inputStream = contentTransfer.accessContentStream();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM