Skip to main content
1-Visitor
October 1, 2010
Question

Short URL for direct download of attachments?

  • October 1, 2010
  • 2 replies
  • 10652 views

If I know the id of an attachment, what is the correct URL I can use to programmatically download the attachment from another machine?

Example: I have a document: wt.doc.WTDocument:167663137 and the primary content is OR:wt.content.ApplicationData:167724372

How do I download the data?

http://xxx/Windchill/servlet/AttachmentsDownloadDirectionServlet/primary?oid=OR:wt.doc.WTDocument:167663137

gives me a page of javascript that will redirect a java-script capable browser to the content at


http://xxx/Windchill/servlet/WindchillGW/wt.fv.master.StandardMasterService/doDirectDownload/Enhancements.xlsm?folderId=150909375&userid=16500377&adId=167724372&fileName=00000000290426&refsize=300369&mime=application/vnd.ms-excel.sheet.macroEnabled.12&mk=wt.fv.master.StandardMasterService&originalFileName=Enhancements.xlsm&sigTime=1285959944&sign=PG6uONw3eHBDJsdqy%2B2ekg%3D%3D&site=http%3A%2F%2Fxxx%2FWindchill%2Fservlet%2FWindchillGW&AUTH_CODE=HmacMD5&isProxy=true

I need to URL to the content (no javascript available). Is there a simpler URL that will give me that?

2 replies

1-Visitor
October 6, 2010

Found my own answer. The ListContent Webject returns a "urlLocation" property, which is what I need.

Also, one of the example TaskDelegates has te code for determining download URL (I'm guessing it's similar to the code that ListContent uses).

tasks/com/ptc/windchill/ws/GetDownloadHandles.xml has the magic bits.

October 22, 2010

use below pseudo code may get the URL:

if (doc.isHasContents()) {
Vector<ApplicationData> contents = (Vector<ApplicationData>) doc.getContentVector();
for (ApplicationData appData : contents) {
java.net.URL url = null;
//some check here
try {
url = ContentHelper.service.getDownloadURL(doc, appData);
}
}
}