public static String getContentType(String key) { Http.MultipartFormData multipartFormData = getContext().request().body().asMultipartFormData(); Http.MultipartFormData.FilePart filePart = multipartFormData.getFile(key); if (filePart != null) { String contentType = filePart.getContentType(); return contentType; } return null; }
public static Result upload() { MultipartFormData body = request().body().asMultipartFormData(); FilePart input = body.getFile("inputFile"); if (input != null) { String fileName = input.getFilename(); String contentType = input.getContentType(); File file = input.getFile(); SeqFile seq = new SeqFile(file); return redirect(routes.Application.results(true)); } else { flash("error", "Missing file"); return redirect(routes.Application.results(false)); } }