How can I read an attachment with the serverside api
Hi all,
for customization project I want to download a workitem attachment to a directory on the server.
Reading Ralphs blog post I know how to download and read an attachment for the client side:
http://rsjazz.wordpress.com/2012/09/21/downloading-attachments-from-work-items/
But I want to try to do it as a serverside plugin where contentManager is not available. I found the following article describing the server side version to read files:
https://jazz.net/forum/questions/102417/abstractscmadvisor-how-do-you-read-changed-file-content
However, IServerSideVersionedContentService needs input of type IVersionable.
How can I download/read IAttachment using the server API?
Thank you!
|
Accepted answer
you can use the IAuditableCommon service
fAuditableCommon = getService(IAuditableCommon.class); OutputStream os = new ByteArrayOutputStream(); fAuditableCommon.retrieveContent(iattachment.getContent(), os, monitor) that gives you the binary data of the attachment Kevin Eifinger selected this answer as the correct answer
Comments
Kevin Eifinger
commented Nov 06 '14, 9:29 a.m.
Thank you!!
sam detweiler
commented Nov 06 '14, 9:33 a.m.
note that you may need to add the IAuditableCommon class to your plugin dependencies list in plugin.xml
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.