on 09-30-2011 7:04 AM
Hi Guys,
I need to save a file uploaded in WebDynpro Java to a location on one of my companys many internal Window servers but I cannot get it to work. I do not get any errors with the following code, but NOTHING happens... And when I check the folder it is still emply... Please advise. I am particularly not sure about specifying the Path syntax. Also, I do have permission to write to this server. Is it even possible to save to a Windows server from WebDynpro??
//uploaded document already in context...
byte[] file = element.getFileResource();
// get the size of the uploaded file
element.setFileSize(this.getFileSize(file));
wdContext.currentContextElement().setFSize(this.getFSize(file));
// get the extension of the uploaded file
element.setFileExtension(binaryType.getMimeType().getFileExtension());
String fName = wdContext.currentContextElement().getFName();
String fExt = wdContext.currentContextElement().getFileExtension();
String foName1 = "
server01.w9\Files\P
HRP_Attachments\" + fName + ".pdf";
File f1 = new File(foName1);
DataOutputStream dos1;
dos1 = new DataOutputStream(new FileOutputStream(f1));
dos1.write(file);
dos1.flush();
dos1.close();
Edited by: christiaanp on Sep 30, 2011 8:07 AM
Hi Christiaan,
When specifying the path, make sure you escape the slashes
So, when you would normally use something like
\\server\path\file.txt
in your code you must use it in the form:
String fileName = "\\\\server\\path\\file.txt";
Hope this helps!
Robin van het Hof
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In retrospect, it's better to use it in following form btw:
String filename = File.seperator + File.seperator + "server" + File.seperator + "path"+ File.seperator + "filename.txt";
to be platform independent, but then I don't think it would solve your issue...
Can you check permissions? The service user under which the NetWeaver application runs (so not the logged in NW user) should have permissions to write to your destination
the file object cannot handle your case
i would suggest you setup ftp server in target server and upload the file using ftp java api, you can use some open source solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.