cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload in Web dynpro

Former Member
0 Kudos

Hello All,

I need one clarification, When we upload file residing in the Local system in WD, where this file present i.e., cache or in other place.

I have one scenarion where we will upoad file and send to other server through webservice, if it fails where this file present.

Thanks and regards,

CSP

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Pradeep Kumar

Just go through this link.It will be help you

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a...

Regards

Ruturaj

Former Member
0 Kudos

hi!

the file get stored on server from client.

for more details check this link

http://help.sap.com/saphelp_erp2004/helpdata/en/5a/90ff4cd0c8cd48a69b836e5e550880/frameset.htm

regards

vishal

former_member192434
Active Contributor
0 Kudos

Hi

When you upload file it resides into WDResource cache of WD

in your case either you can upload file into context and transfer it to the server or directly write to the server ...by useing following code.

public void onActionUploadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionUploadFile(ServerEvent)

String FileName = "temp";//wdContext.currentContextElement().getDirectory();

InputStream input = null;

int i=0;

FileIncreament();

try {

String directory =".
temp
webdynpro
web
local
yh1245_ftp"+

"
Components
com.yash.yh1245.Upload
"FileNamewdContext.currentContextElement().getCounter();

boolean sucsss = new File(directory).mkdir();

if(sucsss){

wdComponentAPI.getMessageManager().reportSuccess("Directory Created ");

File file = new File(directory"
"
wdContext.currentContextElement().getResourceURL().getResourceName().toString());

FileOutputStream fos = new FileOutputStream(file);

wdComponentAPI.getMessageManager().reportSuccess(file.getAbsolutePath());

FilePath = file.getAbsolutePath();

if(wdContext.currentContextElement().getResourceURL()!=null){

input = wdContext.currentContextElement().getResourceURL().read(false);

//wdComponentAPI.getMessageManager().reportSuccess("Resource is not null ");

while((i = input.read())!=-1){

fos.write(i);

}

}

fos.flush();

fos.close();

wdComponentAPI.getMessageManager().reportSuccess("File Uploaded on server directory ");

//wdComponentAPI.getMessageManager().reportSuccess("Created File Locaiton::"+file.getAbsolutePath());

//}

//Get the File Size

// IPrivateFTPUpload.IContextElement element = wdContext.currentContextElement();

// if (element.getResourceURL()!=null) {

// IWDResource resource = element.getResourceURL();

// element.getFileSize(this.getFileSize(resource));

// }

}

}catch(Exception e){

e.printStackTrace();

}

//@@end

}

fore more detail just look into this link

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/607e9392-8167-2b10-b9a8-e0aa297e...

Thanks

Edited by: Anup Bharti on Oct 22, 2008 10:36 AM

Former Member
0 Kudos

Hi,

It will reside on the server. Better you create a directory on server and then upload file to that directory. Go through the following document to create a directory on the server.

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/607e9392-8167-2b10-b9a8-e0aa297e88c6]

Regards

Raghu