10-23-2008 07:47 PM
10-24-2008 04:01 AM
Hello all,
The way I see it, I should use the "read" operation to retrieve all the content, modify it somehow, then use the "write" operation (converting the contents to base64binary… but that's ok)… Assuming that is correct (if it isn't please tell me the right way to proceed), I have trouble with the "read" operation because all it returns is a link to the file/node, and this link leads to a login page before granting access to the file… Which is logical in a way, but then how can I make my third party application access the file itself ?
protected byte[] getContentFromUrl(String contentUrl, String ticket) {
if (ticket != null)
contentUrl += "?ticket=" + ticket;
try {
URL url = new URL(contentUrl);
InputStream is = url.openStream();
byte[] bytes = fillByteArray(is);
is.close();
return bytes;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
byte[] fillByteArray(InputStream is) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[512];
int read = 0;
while ((read = is.read(buffer)) > 0) {
bos.write(buffer, 0, read);
}
return bos.toByteArray();
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.