cancel
Showing results for 
Search instead for 
Did you mean: 

Method createResource to Specify file type of JPG TYPE or DOC type ?

Former Member
0 Kudos

Hi Experts i am using KM API's in WebDynpro JAVA to upload file into the Content Management of

Portal EP7.0. Below is the Code Excerpt, which works fine and file gets uploaded.

Problem is when i browse thru portal to path uploaded on KM i see the file ICON stating it a BINARY

file. How can i change the ICON to read correct type.

is there a way when calling the createResource to state that this file is of JPG TYPE or DOC type.


IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User =
WPUMFactory .getUserFactory().getEP5User(sapUser);
ResourceContext resourseContext = new ResourceContext(ep5User);
RID pathRID = RID.getRID("/documents/Public Documents/MYDATA"); //Root Directory
IResourceFactory resourseFactory =  com.sapportals.wcm.repository.ResourceFactory.getInstance();
ICollection collection = (ICollection)resourseFactory.getResource(pathRID, resourseContext);
}InputStream stream = resource.read(false);
String resourceName = resource.getResourceName();
String resourceExtn = resource.getResourceType().getFileExtension();

com.sapportals.wcm.repository.Content content = 
new com.sapportals.wcm.repository.Content( stream,"application/octet-stream",-1,"UTF-16");

com.sapportals.wcm.repository.IResource new_resource = 
(com.sapportals.wcm.repository.IResource) collection.createResource(resourceName, null, content);

Greetings

Prashant

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi

Have a look on this [Thread|;, where extension type has been checked?

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Satish,

Thanks for the code excerpt. i already know the file type ,

String resourceExtn = resource.getResourceType().getFileExtension();

My problem is that after uploading the file in KM, file is displayed as Binary type... check below tutorial on PAGE 14, the file has icon binary....not the .DOC icon.

[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a099a3bd-17ef-2b10-e6ac-9c1ea42af0e9]

what i want to achieve is since i already know the file type i am uploading the new resource created should be exactly of that type. so if i am uploading .DOC file is shuold see new resource as word document type . Thus it boils down to simple question

  • When creating new resource in KM , whats the way to specify that this is .DOC type resource or .JPEG type resource*

com.sapportals.wcm.repository.IResource new_resource = 
(com.sapportals.wcm.repository.IResource) collection.createResource(resourceName, null, content);

Greetings

Prashant

Answers (1)

Answers (1)

Former Member
0 Kudos

Closed due to further posting requirement