}
// In order to handle foreign characters, the file name is handled in metadata part instead of the FileBody part.
private static MultipartEntityWithProgressListener getNewFileMultipartEntity(final String parentId, final String name, final File file)
throws BoxRestException, UnsupportedEncodingException, BoxJSONException {
MultipartEntityWithProgressListener me = new MultipartEntityWithProgressListener(HttpMultipartMode.BROWSER_COMPATIBLE);
me.addContentBodyPart(Constants.PARENT_ID, new StringBody(parentId));
me.addBoxJSONStringEntityPart(METADATA, getMetadataBody(parentId, name));
if (me.getContentBodyPart(KEY_CONTENT_MODIFIED_AT) == null) {
String date = ISO8601DateParser.toString(new Date(file.lastModified()));
me.addContentBodyPart(KEY_CONTENT_MODIFIED_AT, new StringBody(date));
}
// The contents of the file should come after the part that specifies the parent folder id, so
// that Box's infrastructure can efficiently stream the file to its final destination based on
// the parent folder.
me.addContentBodyPart(KEY_FILE_NAME, new FileBody(file, PLACEHOLDER_FILENAME, "*/*", CharEncoding.UTF_8));
return me;
}