on 06-28-2007 11:44 AM
Hi Guys,
I have a problem here after uploading a file to KM from a webdynpro application. I have written the following code for this purpose.
The problem is that, the file is getting uploaded properly with correct size but when I open it, it shows a message "Unsupported File Format" and then the file comes up blank without any data. The most logical problem could be mimetype setting, but this also I feel I have taken care of.
Please have a look and tell me if I am going wrong somewhere.
Thanks in advance.
-
try {
/*
* Getting the user
*/
IUser sapUser = WDClientUser.getCurrentUser().getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User = null;
try {
ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
} catch (UserManagementException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return false;
}
/*
* Getting the Resource
*/
ResourceContext resContext = new ResourceContext(ep5User);
/*
* Path to KM Folder
*/
RID pathKMFile = RID.getRID("/documents/FsapPOC/");
IResourceFactory resFactory = null;
ICollection parentDirectory = null;
try {
resFactory = ResourceFactory.getInstance();
parentDirectory = (ICollection) resFactory.getResource(pathKMFile, resContext);
} catch (ResourceException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
return false;
}
IContent objContent = null;
try {
try {
IMutablePropertyMap propertyMap = new MutablePropertyMap();
ByteArrayInputStream bytArrIpStream = new ByteArrayInputStream(this.getByteArray(wdContext.currentContextElement().getResFileAttachmentUpload().read(false)));
objContent = new Content(bytArrIpStream,wdContext.currentContextElement().getResFileAttachmentUpload().getResourceType().getHtmlMime(),bytArrIpStream.available());
IResource resource = parentDirectory.createResource(wdContext.currentContextElement().getResFileAttachmentUpload().getResourceName(),propertyMap,objContent);
} catch (NotSupportedException e7) {
// TODO Auto-generated catch block
wdComponentAPI.getMessageManager().reportSuccess("NotSupportedException #### - "+e7.getMessage());
return false;
} catch (AccessDeniedException e7) {
// TODO Auto-generated catch block
wdComponentAPI.getMessageManager().reportSuccess("AccessDeniedException #### - "+e7.getMessage());
return false;
} catch (ResourceException e7) {
// TODO Auto-generated catch block
wdComponentAPI.getMessageManager().reportSuccess("ResourceException #### - "+e7.getMessage());
return false;
}
} catch (IOException e6) {
// TODO Auto-generated catch block
e6.printStackTrace();
return false;
}
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
-
Eagerly awaiting any answers from you guys.
Regards,
Jitendra Chaudhari
Hi ,
You have to define the encoding type as UTF-8 while retrieving the file.
Regards
Bharathwaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.