on 03-31-2011 9:51 AM
Hi Experts,
Can you please guide me with the steps( or a document) to upload a photo file using Webdynpro Java application on any Content server?
Kindly assist.
Regards,
Anurag
upload is quite easy, just one button click.
you can search in sdn, there is a lot of upload example.
the question is how to store it in the content server, but you didn't tell us the what server it is ,no one can help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kindly assist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I dont get your requirement clearly
But you can upload a photo/document in the ce server using UI element upload
Use the following code for upload action
The code is for both upload and download
File file = new File("file path
");
if (!file.exists()) {
file.mkdirs();
}
String OriginalFileName = wdContext.currentUIuploadElement()
.getFILEUPLOAD().getResourceName();
int length = OriginalFileName.lastIndexOf(".");
String fileName = OriginalFileName.substring(0, length - 1);
fileName += new Date().getTime();
fileName += OriginalFileName.substring(length, OriginalFileName
.length());
wdComponentAPI.getMessageManager().reportSuccess(
"saved as : " + fileName);
try {
FileOutputStream out = new FileOutputStream(".
NUS_DOCs
"
+ fileName);
InputStream input = wdContext.currentUIuploadElement()
.getFILEUPLOAD().read(true);
int c = -1;
while ((c = input.read()) != -1) { out.write(c);
}
out.close();
input.close();
wdComponentAPI.getMessageManager().reportSuccess(
"Document Uploaded sucessfully");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
File file1 = new File(".
NUS_DOCs
" + fileName);
if (file1.exists()) {
String resourcePath = file1.getAbsolutePath();
IUIdownloadElement documentNodeElement = wdContext
.createAndAddUIdownloadElement();
documentNodeElement.setFILENAME(OriginalFileName);
documentNodeElement.setUrl(resourcePath);
IWDResource resource = null;
try {
wdComponentAPI.getMessageManager().reportSuccess(
"URL generated :" + resourcePath);
resource = WDResourceFactory.createResource(
new FileInputStream(new File(resourcePath)),
OriginalFileName, WDWebResourceType.UNKNOWN, true);
wdComponentAPI.getMessageManager().reportSuccess(
"Resource generated sucessfully");
documentNodeElement.setFILEUPLOAD(resource);
} catch (FileNotFoundException e) {
wdComponentAPI.getMessageManager().reportException(
"FileNotFoundException");
e.printStackTrace();
}
}
Hope this works for you
Best regards
suresh joshi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
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.