Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

Can we download the files attached to workitems in RTC?

I need to export files attached to multiple work items in one folder. is this possible using any plug in.

0 votes



2 answers

Permanent link

You can create yourself a tool: https://rsjazz.wordpress.com/2012/09/21/downloading-attachments-from-work-items/

0 votes


Permanent link

I have done that in a plugin (follow-up action), using server-side Java API.

This works for only one work item, but you can use thes snippets as a starting point, by adapting them to plain Java API.

public IAttachment getAttachment (IWorkItem workItem)
    throws TeamRepositoryException {
    IAttachment attachment = null;
    IWorkItemReferences workItemReferences = saveParameter.getNewReferences();
    List<IReference> attachmentReferencesList = workItemReferences.getReferences(WorkItemEndPoints.ATTACHMENT);
    for (IReference attachmentReference : attachmentReferencesList) {
    if (attachmentReference.isItemReference()) {
IItemHandle referencedItem = ((IItemReference) attachmentReference).getReferencedItem();
String itemKind = referencedItem.getItemType().getName();
if (referencedItem instanceof IAttachmentHandle) {
attachment = (IAttachment) repositoryItemService.fetchItem(referencedItem, IRepositoryItemService.COMPLETE);
break;
}
    }
    }
    return attachment;
}
  
public boolean saveAttachment(IAttachment attachment)
    throws TeamRepositoryException {   
    boolean saved = false;
    try {
    String attachmentName = attachment.getName();
    String attachmentPath = attachmentsFolder + "\" + attachmentName;
    File save = new File(attachmentPath);
    OutputStream out = new FileOutputStream(save);
    try {
    contentService.retrieveContent(attachment.getContent(), out);
    } finally {
    out.close();
    }
    saved = true;
    } catch (FileNotFoundException e) {
    saved = false;
    } catch (IOException e) {
    saved = false;
    }
    return saved;
}

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,060

Question asked: Oct 09 '17, 8:53 a.m.

Question was seen: 4,089 times

Last updated: Oct 10 '17, 2:44 a.m.

Confirmation Cancel Confirm