on 08-10-2016 8:44 AM
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
may i ask why you've opened a new thread (previous thread http://scn.sap.com/thread/3930784 /)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Workbook wb = Workbook.getWorkbook(new File(path));
create wb from stream directly, no need to save to disk....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i get stream directly as below
Workbook wb = Workbook.getWorkbook(wdContext.currentContextElement().getMy_Resource().read(false));
it's still error, think there is something wrong when return wdContext.currentContextElement().getMy_Resource().read(false) . maybe SC of NWDS cause this issue ? I'm using SAP NetWeaver Developer Studio 7.3 SP18 PAT0002
Thanks
Hi hhoang,
did you compare the two files yet (the original and the uploaded one from the server)?
Maybe you can see the difference there or the point where the "corruption" starts.
Regards Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.