agave-systems/systems-core/src/main/java/org/iplantc/service/transfer/http/HTTP.java
/**
	 * Makes multipart/form post to path with given form params, headers, and files.
	 * @param path
	 * @param mappedFormParameters
	 * @param localFiles
	 * @param mappedHeaders
	 * @return raw http response object with entity in tact
	 * @throws IOException
	 * @throws RemoteDataException
	 */
Makes multipart/form post to path with given form params, headers, and files.
Makes multipart / form post to path with given form params headers and files .
@SuppressWarnings("deprecation")
	public CloseableHttpResponse doPostMultipart(String path, Map<String, String> mappedFormParameters, File[] localFiles, Map<String, String> mappedHeaders)
	throws IOException, RemoteDataException
	{
		try 
		{
			URI escapedUri = getUriForPath(path);
			HttpPost httpPost = new HttpPost(escapedUri);
			MultipartEntityBuilder multipartBuilder = MultipartEntityBuilder.create();
			for (File file: localFiles) {
				if (file == null) {
					throw new FileNotFoundException("Null file specified in array of files");
				} else if (file.isDirectory()) {
					throw new IOException("Directory upload is not supported.");
				} else {
					multipartBuilder.addPart("fileToUpload", new FileBody(file));
				}
			}
		    if (mappedFormParameters != null && !mappedFormParameters.isEmpty()) 
		    {
		    	for (String key: mappedFormParameters.keySet()) {
		    		multipartBuilder.addPart(key, new StringBody(mappedFormParameters.get(key)));
		    	}
		    }
		    httpPost.setEntity(multipartBuilder.build());
		    if (mappedHeaders != null && !mappedHeaders.isEmpty()) 
		    {
		    	for (String key: mappedHeaders.keySet()) {
		    		httpPost.addHeader(key, mappedHeaders.get(key));
		    	}
		    }
			return doRequest(escapedUri, httpPost);
		}
		catch (IOException e) {
			throw e;
		}
		catch (Exception e) {
			throw new RemoteDataException("Failed to post multipart form to " + path, e);
		}
	}
@ SuppressWarnings ( "deprecation" ) public CloseableHttpResponse doPostMultipart ( String path , Map < String , String > mappedFormParameters , File [ ] localFiles , Map < String , String > mappedHeaders ) throws IOException , RemoteDataException { try { URI escapedUri = getUriForPath ( path ) ; HttpPost httpPost = new HttpPost ( escapedUri ) ; MultipartEntityBuilder multipartBuilder = MultipartEntityBuilder . create ( ) ; for ( File file : localFiles ) { if ( file == null ) { throw new FileNotFoundException ( "Null file specified in array of files" ) ; } else if ( file . isDirectory ( ) ) { throw new IOException ( "Directory upload is not supported." ) ; } else { multipartBuilder . addPart ( "fileToUpload" , new FileBody ( file ) ) ; } } if ( mappedFormParameters != null && ! mappedFormParameters . isEmpty ( ) ) { for ( String key : mappedFormParameters . keySet ( ) ) { multipartBuilder . addPart ( key , new StringBody ( mappedFormParameters . get ( key ) ) ) ; } } httpPost . setEntity ( multipartBuilder . build ( ) ) ; if ( mappedHeaders != null && ! mappedHeaders . isEmpty ( ) ) { for ( String key : mappedHeaders . keySet ( ) ) { httpPost . addHeader ( key , mappedHeaders . get ( key ) ) ; } } return doRequest ( escapedUri , httpPost ) ; } catch ( IOException e ) { throw e ; } catch ( Exception e ) { throw new RemoteDataException ( "Failed to post multipart form to " + path , e ) ; } }
Makes multipart/form post to path with given form params, headers, and files.
Makes multipart / form post to path with given form params headers and files .
// add files // add forms params // add headers // make request