I created a website that will upload files to a webdav server
I can now upload files to the webdav server and I am able to view it.
below is my code
<%
boolean isMultiPart = FileUpload.isMultipartContent(request);
DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
String baseUrl = "http://localhost:8084/webdavserver";
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
File fullFile = new File(item.getName());
File savedFile = new File(getServletContext().getRealPath("/"),
fullFile.getName());
System.out.println("fullFile: "+fullFile);
System.out.println("savedFile: "+savedFile);
item.write(savedFile);
try {
HttpClient client = new HttpClient();
Credentials creds = new UsernamePasswordCredentials("myuser", "mypass");
client.getState().setCredentials(AuthScope.ANY, creds);
PutMethod method = new PutMethod(baseUrl + "/uploads/" + savedFile.getName());
System.out.println("path: "+fullFile);
RequestEntity requestEntity = new InputStreamRequestEntity( new FileInputStream(savedFile.getAbsolutePath()));
method.setRequestEntity(requestEntity);
client.executeMethod(method);
System.out.println("uploaded: "+method.getStatusCode() + " " + method.getStatusText());
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
response.sendRedirect(request.getContextPath());
}
%>
I use tomcat as my server for webdav
questions:
How can I retrieve my uploaded files?
I noticed also that the files I uploaded are not on webdav repository so If I clean and build the server
all files are gone.
anybody can help me...
I am stuck on this for days.