private static MultipartEntityWithProgressListener getNewFileMultipartEntity(final String parentId, final String name, final File file)
throws BoxRestException, UnsupportedEncodingException {
MultipartEntityWithProgressListener me = new MultipartEntityWithProgressListener(HttpMultipartMode.BROWSER_COMPATIBLE);
me.addPart(Constants.FOLDER_ID, new StringBody(parentId));
me.addPart(KEY_FILE_NAME, new FileBody(file, KEY_FILE_NAME, "", CharEncoding.UTF_8));
me.addPart(METADATA, getMetadataBody(parentId, name));
String date = ISO8601DateParser.toString(new Date(file.lastModified()));
if (me.getPart(KEY_CONTENT_CREATED_AT) == null) {
me.addPart(KEY_CONTENT_CREATED_AT, new StringBody(date));
}
if (me.getPart(KEY_CONTENT_MODIFIED_AT) == null) {