* @param name name of the file once uploaded.
* @return reference to remote file on AppThwack.
*/
public AppThwackFile uploadFile(File file, String name) throws AppThwackException {
if(file == null) {
throw new AppThwackException("file cannot be null");
}
if(name == null || name.isEmpty()) {
throw new AppThwackException("name cannot be null or empty");
}
if(!file.exists()) {
throw new AppThwackException("file does not exist");
}
if(!file.isFile()) {
throw new AppThwackException("file cannot be a directory");
}
FormDataMultiPart form = new FormDataMultiPart();
form.field("name", name);
form.bodyPart(new FileDataBodyPart("file", file, MediaType.APPLICATION_OCTET_STREAM_TYPE));