10-13-2009 11:14 AM
contentUrl=store://2009/10/13/10/41/fb64d4a3-f652-4a45-9e3e-42cefbb585bf.bin|mimetype=text/plain|size=0|encoding=utf-8|locale=en_US_
but getting the file itself is a mystery to me…10-13-2009 04:56 PM
10-14-2009 03:16 AM
10-14-2009 08:09 AM
private static void makeFile(MigrateDocument doc) throws Exception {
//start session
AuthenticationDetails details = startSession(getUser(), getPass());
//get contentService
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
//create reference to document with the uuid encapsulated in my MigrateDocument
Reference ref = new Reference(getStore(), doc.getUuid(), null);
//read the content
Content[] readResult = contentService.read(new Predicate(new Reference[]{ref}, getStore(), null), Constants.PROP_CONTENT);
for (Content content : readResult) {
String[] splittedUrl = content.getUrl().split("/");
if(splittedUrl[splittedUrl.length-1].equals(doc.getName())){
//this if-clause makes sure it's the right thing to download BUT be sure to have replaced all whitespace in the filename by a '+' or the equals will return false!
InputStream in = ContentUtils.getContentAsInputStream(content);
BufferedInputStream bis = new BufferedInputStream(in);
//find location to place the downloaded file
String path = getPhysicalPaths().get(doc.getParent().getUuid());
//write
FileOutputStream fos = new FileOutputStream(path + doc.getName());
BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);
byte data[] = new byte[1024];
int count;
while((count = bis.read(data, 0, 1024)) != -1){
bos.write(data, 0, count);
}
bos.close();
bis.close();
}
}
//end session
endSession(details);
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.