cancel
Showing results for 
Search instead for 
Did you mean: 

Upload CSV file (WDA)

Former Member
0 Kudos

Hi. everyone.

I have some question about file upload.

I really wanna upload a csv file(text file),

but as you know,

It is not possible to use FileUpload UI control.

Because the UI element supports binary upload.

How can I upload a csv file and

map the file contents to a Node which has same structure as the csv file.

Plz. help me^^

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Etnaya,

You can upload the binary file and then convert it to inputstream and through inputstream you can use to write into the file in the server.Here is the code for this:

Resource : is the attribute of type resource

UploadFile: is value Node under which Resource attribute is present.

IPrivateFileupView.IUploadFileElement element =

wdContext.currentUploadFileElement();

InputStream text = element.getResource().read(false);

File file = new File(element.getResource().getResourceName());

FileOutputStream out = new FileOutputStream(file);

int i=0;

int temp=0;

while((temp=text.read())!=-1)

{

out.write(temp);

}

//This will give you the path where the file is stored

filePath=file.getAbsolutePath();

wdComponentAPI.getMessageManager().reportSuccess("label"+ file.getAbsolutePath());

text.close();

out.flush();

Hope this will help you.

Regards,

Rajeev