Hi everyone,
I used fileupload in web dynpro for java 7.4, i'm facing an issue "corrupted content" when upload an excel file to server.
resouce type: com.sap.ide.webdynpro.uielementdefinitions.Resource
My code :
try{
IPrivateMyCompView.IContextElement element = wdContext.currentContextElement();
if(element.getMyResource()!=null){
InputStream in = null;
int temp = 0;
File file = new File(wdContext.currentContextElement().getMyResource().getResourceName());
FileOutputStream out = new FileOutputStream(file);
in = element.getMyResource().read(false);
while((temp = in.read())!=-1){
out.write(temp);
}
out.flush();
out.close();
path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess("path: "+path);
// path = usr/sap/DEP/J00/j2ee/cluster/server0/Book1.xls
try {
Workbook wb = Workbook.getWorkbook(new File(path));
} catch (BiffException e) {
wdComponentAPI.getMessageManager().reportException("BiffException: "+e.getMessage());
e.printStackTrace();
}
}
}catch (FileNotFoundException e){
wdComponentAPI.getMessageManager().reportException("FileNotFoundException: "+e.getMessage());
e.printStackTrace();
}catch (IOException e){
wdComponentAPI.getMessageManager().reportException("IOException: "+e.getMessage());
e.printStackTrace();
}
Please help me
Thanks & Best Regard,
hhoang