cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to extract the image attachment and display in html?

acheong
4-Participant

How to extract the image attachment and display in html?

I am trying to extract an image from the Document workflow. (See attached)

 

The respective jsp file code for this is :

   ArrayList attachement = (ArrayList) getFieldValue (cmdRunner, childId, "Text Attachments");
   if (attachement != null && attachement.size () > 0) {
    if (text.length () > 0) {
     text += "<br>";
    }
    text = text + "<b>&lt;&lt;Attachment&gt;&gt;</b>"; // This line seem in correct.

 

Any body know how to extract the image ?

Appreciate your help.

 


      
   
   

2 REPLIES 2
awalsh
17-Peridot
(To:acheong)

Do you need to download the image, or just add a link to it? 

For a link, you need to know the Attachment field ID (in this case the ID for "Text Attachments" which you can get by running im fields --fields=id,name "Text Attachments"). ), the attachment name, and the item number:

 

http://servername:port/im/viewattachment?issue=itemid&attachment=attachmentname&fieldID=attachmentfieldID

 

To get the attachment name, use getAttachments("Text Attachments") to get an array of the attachment names.

 

If you need to download the image, then you need to use the attachment bean: getAttachmentBeans("Text Attachments")

From the attachment bean, you can get the contents of the attachment using getContent(java.io.OutputStream out).

acheong
4-Participant
(To:awalsh)

Dear awalsh,

Thanks very much for the help.

I still working on it, I will update again regarding the outcome.

 

Thanks verymuch

Andy

 

 

 

Announcements


Top Tags