Skip to content

Instantly share code, notes, and snippets.

@lifuzu
Created September 19, 2013 20:45
Show Gist options
  • Save lifuzu/6629594 to your computer and use it in GitHub Desktop.
Save lifuzu/6629594 to your computer and use it in GitHub Desktop.
Get filename option from http request header
/**
* @param part
* @return
*/
private String getFileName(final Part part) {
final String partHeader = part.getHeader("content-disposition");
for (String content : partHeader.split(";")) {
if (content.trim().startsWith("filename")) {
return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment