Skip to content

Commit

Permalink
Fix uploading to subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Jun 24, 2013
1 parent 6ff68a5 commit 15765ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hawtio-web/src/main/java/io/hawt/web/UploadServlet.java
Expand Up @@ -105,6 +105,11 @@ public void update(long pBytesRead, long pContentLength, int pItems) {

LOG.info("Got file upload, fieldName: {} fileName: {} contentType: {} size: {}", new Object[]{fieldName, fileName, contentType, sizeInBytes});

if (fileName.equals("")) {
LOG.info("Skipping field " + fieldName + " no filename given");
continue;
}

File target = new File(UPLOAD_DIRECTORY + File.separator + fileName);

try {
Expand All @@ -113,12 +118,12 @@ public void update(long pBytesRead, long pContentLength, int pItems) {
LOG.info("Wrote to file: {}", target.getAbsoluteFile());
} catch (Exception e) {
LOG.warn("Failed to write to {} due to {}", target, e);
throw new RuntimeException(e);
//throw new RuntimeException(e);
}
}
}
} catch (FileUploadException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
throw new RuntimeException ("Failed accepting file uploads: ", e);
}

if (targetDirectory != null) {
Expand Down

0 comments on commit 15765ab

Please sign in to comment.