Quantcast
Channel: PTC Community: Message List - Windchill
Viewing all articles
Browse latest Browse all 8876

Re: How to download & Save WTDocument primary content using Windchill API ?

$
0
0

Hi Manikandan,

 

Please try the following code in  any utility class,

 

ContentHolder content = ContentHelper.service.getContents((ContentHolder)documentObject); 

Vector<?> vcontent = ContentHelper.getApplicationData(content); // this will return all contents

if(vcontent.size() > 0){

for(int i=0; i<vcontent.size(); i++) {                  

  wt.content.ApplicationData appData = (ApplicationData)vcontent.get(i);

  String currfileName = appData.getFileName();

  File saveAsFile= new java.io.File("D:/",currfileName); // input your location and file name

  ContentServerHelper.service.writeContentStream((ApplicationData)appData, saveAsFile.getCanonicalPath());

}

}

 

you can also download the content for role too, have look on following method and modify to suit your requirement,

 

QueryResultgetContentsByRole(ContentHolder holder,   ContentRoleType role)  throws WTException

 

public static final ContentRoleTypePRIMARY

public static final ContentRoleTypeSECONDARY

 

Njoy,

 

MKR


Viewing all articles
Browse latest Browse all 8876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>