public MultipartUploadRequest addFileToUpload ( String filePath , String parameterName , String fileName , String contentType ) throws FileNotFoundException , IllegalArgumentException { UploadFile file = new UploadFile ( filePath ) ; filePath = file . getPath ( ) ; if ( parameterName == null || "" . equals ( parameterName ) ) { throw new IllegalArgumentException ( "Please specify parameterName value for file: " + filePath ) ; } file . setProperty ( MultipartUploadTask . PROPERTY_PARAM_NAME , parameterName ) ; if ( contentType == null || contentType . isEmpty ( ) ) { contentType = file . getContentType ( context ) ; Logger . debug ( LOG_TAG , "Auto-detected MIME type for " + filePath + " is: " + contentType ) ; } else { Logger . debug ( LOG_TAG , "Content Type set for " + filePath + " is: " + contentType ) ; } file . setProperty ( MultipartUploadTask . PROPERTY_CONTENT_TYPE , contentType ) ; if ( fileName == null || "" . equals ( fileName ) ) { fileName = file . getName ( context ) ; Logger . debug ( LOG_TAG , "Using original file name: " + fileName ) ; } else { Logger . debug ( LOG_TAG , "Using custom file name: " + fileName ) ; } file . setProperty ( MultipartUploadTask . PROPERTY_REMOTE_FILE_NAME , fileName ) ; params . files . add ( file ) ; return this ; }
Adds a file to this upload request .