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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

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

ManikandanVelay
1-Newbie

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

I have a requirement like I need to download either primary or secondary content to WC Server Local HardDisk.

I am able to achive this using desktop.getdesktop().browse(new uri(Windchill_DocDownload_URL)) . If any better method is there please suggest.

2 REPLIES 2

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,

QueryResult getContentsByRole(ContentHolder holder, ContentRoleType role) throws WTException

public static final ContentRoleType PRIMARY

public static final ContentRoleType SECONDARY

Njoy,

MKR

Thanks a lot brother.

getContentsByRole(ContentHolder holder, ContentRoleType role) is perfect solution for my requirement.

and also I tried your above code ,In that if(vcontent.size() > 0) always not entering.

By

Mani

Announcements

Top Tags