I’m confused a little, you say:
…I need to read a csv file that the User uploaded. For reading the file I have no problems…
then you say
…I can not read the file…
either you can or you can’t…
Whichever you cannot get the path C:\user\my documents\thisfile.csv to a local users file
I posted this on a different post before http://community.bonitasoft.com/answers/upload-file-get-its-source-path :
The whole idea of web services is that the browser/web will not have access to local files, only those in the web servers path.
We struggled with this I now remember, spent a long time figuring it out and found it was impossible.
Our process is now quite simple
*User loads the file,
we save it to either a webserver folder (under tomcat/Catalina) or to a database (in our case Postgres)
then later in many other processes we access and edit the files as necessary…
*
No need for any client access at all, with all the necessary security benefits as well.
If you want the INTERNAL path to the uploaded file then use getURL() (see the javadoc).
I do this a lot and have no problems at all reading writing files without the path being known. For example reading, opening and processing a file I do something like this, you will need to change it as it’s not complete… can’t give away all my secrets
//Open input Stream
ByteArrayInputStream str = new ByteArrayInputStream(documentData.getContent()); // documentData is the Document uploaded
//read the whole file
StringBuilder sb = new StringBuilder();
int ch;
while((ch = str.read()) != -1) {
sb.append(Character.toString((char) ch));
}
//read file into a ArrayList splitting each line into a separate line
String tempL = sb.toString();
String tempLA = tempL.split(“\r?\n”);
ArrayList configLines = new ArrayList(Arrays.asList(tempLA));
//process each line of the input file
for (int lNo=0; lNo<configLines.size(); lNo++){
//do what you need to do
}
Hope that helps, but your quest for the path is a vain one, and not possible purely for security reasons, this is true of all browsers now.
regards