private Part createMultipart(String fileParamName, RestMultipart restMultipart) { RestMultipart.RestMultipartType type = restMultipart.getType(); switch (type) { case FILE: String fileName = null; try { fileName = restMultipart.getValue(); File file = new File(fileName); FilePart filePart = new FilePart(fileParamName, file, restMultipart.getContentType(), restMultipart.getCharset()); LOG.info("Configure Multipart file upload paramName={} : ContentType={} for file={} ", new String[]{ fileParamName, restMultipart.getContentType(), fileName}); return filePart; } catch (FileNotFoundException e) { throw new IllegalArgumentException("File not found: " + fileName, e); } case STRING: StringPart stringPart = new StringPart(fileParamName, restMultipart.getValue(), restMultipart.getCharset()); stringPart.setContentType(restMultipart.getContentType()); LOG.info("Configure Multipart String upload paramName={} : ContentType={} ", fileParamName, stringPart.getContentType()); return stringPart; default: throw new IllegalArgumentException("Unknonw Multipart Type : " + type); } }