cancel
Showing results for 
Search instead for 
Did you mean: 

Upload a photo using Webdynpro Java application on any content server

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

junwu
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi John,

Sorry for the inconvenience.

I've to upload the files from the client machine to some content server(data management server) using Web dynpro java application.

I hope, I am able to explain my requirement!!!

Best Regards,

Anurag

Qualiture
Active Contributor
0 Kudos

If it's simply a file server, your application needs to have at least write access (via file transfer, ftp transfer, webdav, etc) to your content server. This output process is standard Java functionality

Former Member
0 Kudos

Hi All,

The requirement has been modified, hence closing the thread.

Regards,

Anurag

Former Member
0 Kudos

Kindly assist.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

The requirement is to upload a file using a web dynpro java application on a content server.

Can anyone please share the code for the same?

Thanks in advance.

Best Regards,

Anurag