on 08-25-2006 6:54 PM
Hello everyone,
I'm trying to download files (of any type) from a KM directory in my webdynpro application.
I allready used the tutorial from SAP, but it consists only on navigating through the KM content.
I have a UI Table that lists all files from a specific directory of KM. It works fine. But now, how can i download it's content?
My example:
private void loadTable(){
IWDMessageManager manager = wdComponentAPI.getMessageManager();
wdContext.nodeFiles().invalidate();
try {
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
IResourceContext resourceContext = new ResourceContext(ep5User);
IResourceFactory resourceFactory = ResourceFactory.getInstance();
RID pathRID = RID.getRID("/directory");
IResource resource = resourceFactory.getResource(pathRID, resourceContext);
ICollection collection = (ICollection) resource;
IResourceList resourceList = collection.getChildren();
IResourceListIterator resourceListIterator = resourceList.listIterator();
while (resourceListIterator.hasNext()) {
IPrivateFormView.IFilesElement elem = wdContext.createFilesElement();
tempResource = resourceListIterator.next();
elem.setName(tempResource.getName());
wdContext.nodeFicheiros().addElement(elem);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Thanks in advance for any help.
Nuno Santos
Hi,
Give a try with this piece of code.
aRid = RID.getRID("/RepositoryName");
IResource resource =
resourceFactory.getResource(aRID, resourceContext);
//Get Content
IContent content = resource.getContent();
//Read Content
InputStream IStream = content.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
//out is to store the content of the file from KM
byte[] buffer = new byte[4096];
int bytesread = 0;
while ((bytesread = IStream.read(buffer)) != -1) {
out.write(buffer, 0, bytesread);
}
The above code is an extract from the following link
https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/6615ea90-0201-0010-be81-e7a300fdf212
Hope this is helpful.
Regards,
Santhosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.