cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload and download documents to KM through webdynpro

Former Member
0 Kudos

Hi,

I have been trained in Netweaver XI and now my project needs to develop applications in webdynpro.I have some idea related webdynpro, Now i need to upload and download documents in to KM through webdynpro. Could any one of you please help me out how to upload and download documents to KM through webdynpro.

Thank you

Regards

Lakshmi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

chk it

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Pl go through this blog

/people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis

REgards

Ayyapparaj

Former Member
0 Kudos

hi,

check the following code to upload files in km.

String actualFileName=null;

try

{

/*Get an object of current Portal user */

IWDClientUser clientUser=WDClientUser.getCurrentUser();

IUser sapUser=clientUser.getSAPUser();

com.sapportals.portal.security.usermanagement.IUser ep5User=WPUMFactory.getUserFactory().getEP5User(sapUser);

ResourceContext context=new ResourceContext(ep5User);

/*Give the path to KM in the variable path */

String path="/documents/Public Documents";

RID rid=RID.getRID(path);

IResourceFactory factory=ResourceFactory.getInstance();

ICollection folder=(ICollection)factory.getResource(rid,context);

/*Using the upload element we can upload the files to a location in the server drive

/*temporary location for writing */

IWDResource res=wdContext.currentContextElement().getFResource();

InputStream ist=res.read(true);

byte b[]=new byte[ist.available()];

ist.read(b);

ist.close();

actualFileName=res.getResourceName();

File f=new File("
"+actualFileName);

FileOutputStream fos=new FileOutputStream(f);

fos.write(b);

fos.close();

/From the temporary location read the file using an input stream/

FileInputStream is = new FileInputStream(f);

/*Using this input stream we can write to the repository

String fileName=res.getResourceName();

Content con = new Content(is, wdContext.currentContextElement().getFResource().getResourceType().getHtmlMime(), -1);

IResource newResource = folder.createResource(fileName, null, con);

is.close();

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException("1 "+e,true);

}

finally

{

File f=new File("
"+actualFileName);

f.delete();

}

regards,

krishnaveni

Former Member
0 Kudos

Hi

Check the blog

<a href="/people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis

also you can see

/thread/327964 [original link is broken]

Regards

Abhijith YS