OpenNTF/SocialSDK

Connections file download doesn't work?

Opened this issue · 0 comments

I'm trying to download a file from Connections using this code:

FileService service = new FileService();
EntityList<File> myFiles = service.getMyFiles();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
service.downloadFile(stream, myFiles.get(0).getFileId());

The Connections server returns:

<?xml version="1.0" encoding="UTF-8"?><td:error xmlns:td="urn:ibm.com/td"><td:errorCode>UnsupportedOperation</td:errorCode></td:error>

I get the same result on my company Connections server and on Greenhouse (long may it live).

The URL being sent to the Connections server is of this format:

files/basic/api/myuserlibrary/file/{FILEID}//media

Looking at the Connections API documentation (from at least version 3 on up), it appears that the /file/ part of the URL just before the FileID is actually supposed to be /document/
https://www-10.lotus.com/ldd/lcwiki.nsf/dx/Downloading_a_file_ic55

Also, the Connections server doesn't seem to like the double-forward slash after the file ID (//media). This URL works fine:

files/basic/api/myuserlibrary/document/{FILEID}/media

It looks like this would be a simple change in com.ibm.sbt.services.client.connections.files.FileUrls, but I was hoping that someone could check me on this (and officially change it). Thanks!