cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload file through WebDynpro to KM repository

dhruv_shah3
Active Contributor
0 Kudos

Hi All,

I want to upload a file from webdynpro to KM repository.

The file is to be pick from the end user place.

and then it is to be uploaded in KM.

So pls send me some links of Documents for achieving this.

Thanks & Regards,

Dhruv Shah

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi see this links i hope it will help in some extent

/thread/29720 [original link is broken]

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f02b492c-7d76-2a10-86aa-e11e8388...

Thanks,

Tulasi Palnati

Answers (1)

Answers (1)

PradeepBondla
Active Contributor
0 Kudos

Hi,

Check the links inside this thread

https://www.sdn.sap.com/irj/sdn/thread?threadID=564552

and also https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/Tutorial%20o...

Here is the code by ERAY for the same.... in the thread https://www.sdn.sap.com/irj/sdn/thread?threadID=564552

try{
com.sap.security.api.IUser sapUser = com.sap.security.api.UMFactory.getAuthenticator().forceLoggedInUser(request,response);
sapUser.getAccessibilityLevel();
com.sapportals.portal.security.usermanagement.IUser ep5User = 
com.sapportals.wcm.util.usermanagement.WPUMFactory.getUserFactory().getEP5User(sapUser);
 
ResourceContext context = new ResourceContext(ep5User);
/*Give the path to KM in the variable path */
RID rid = RID.getRID("/documents/DENEME");
IResourceFactory factory = ResourceFactory.getInstance();
ICollection folder = (ICollection) factory.getResource(rid,context); 
String location = "E:\DynproTempFolder\";
String fileName = location+"a.pdf";
File file = new File(fileName);
 
// IResource res_forMap = ResourceFactory.getInstance().getResource(rid, context);
// IPropertyMap pm = res_forMap.getProperties();
 
String mime = new MimetypesFileTypeMap().getContentType(file);
 
 
/*Create an output stream for writing to the temperory location*/ 
/*From the temporary location read the file using an input stream*/
 
FileInputStream fin = new FileInputStream(fileName);
// fin.read();
 
/*Using this input stream we can write to the repository
Content content = new Content(fileelement.getFiledata(),fileelement.get) */
 
 
Content content = new Content(fin,"byte", -1L);
 
IResource newResource = folder.createResource("a.pdf",null,content);
 
 
fin.close();
//file.delete();

PradeeP

Edited by: pradeep bondla on Aug 1, 2008 8:52 AM