/** * Adds a binary file part * * @param parameterName The name of the parameter * @param parameterFile The name of the file. * @throws FileNotFoundException If the file cannot be found. */ public void addParameter(String parameterName, File parameterFile) throws FileNotFoundException { LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, " + "File parameterFile)"); Part param = new FilePart(parameterName, parameterFile); parameters.add(param); }
/** * Adds a binary file part with the given file name * * @param parameterName The name of the parameter * @param fileName The file name * @param parameterFile The file * @throws FileNotFoundException If the file cannot be found. */ public void addParameter(String parameterName, String fileName, File parameterFile) throws FileNotFoundException { LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, " + "String fileName, File parameterFile)"); Part param = new FilePart(parameterName, fileName, parameterFile); parameters.add(param); }
@Override public Http3ResponseBuilder withParam(String name, File value, String mimeType) throws IOException { this.fileParams.put(name, new FilePart(name, value, mimeType, null)); return this; }
import com.ning.http.client.AsyncHttpClient import com.ning.http.client.multipart.FilePart AsyncHttpClient myClient = ws.getUnderlying(); FilePart myFilePart = new FilePart("myFile", new java.io.File("test.txt")) myClient.preparePut("http://localhost:9000/index").addBodyPart(filePart).execute.get()
File f = new File("C://xxx/test.txt"); Part[] parts = { new FilePart("test", f) }; postMethod.setRequestEntity( new MultipartRequestEntity(parts, postMethod.getParams()) );
List < Part > files = new ArrayList(); for (int i = 0; i < imageFiles; i++) { files.add(new FilePart("UploadForm[" + i + "]", new File(imgFile.get(i).getName()))); } Ion.with(MainActivity.this) .load(Constant.UPLOAD_IMG) .addMultipartParts(files) .asJsonObject() .setCallback(new FutureCallback < JsonObject > () { @Override public void onCompleted(Exception e, JsonObject result) {} });
/** * Adds a binary file part with the given file name * * @param parameterName The name of the parameter * @param fileName The file name * @param parameterFile The file * @throws FileNotFoundException If the file cannot be found. */ public void addParameter(String parameterName, String fileName, File parameterFile) throws FileNotFoundException { LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, " + "String fileName, File parameterFile)"); Part param = new FilePart(parameterName, fileName, parameterFile); parameters.add(param); }
File file = new File("file-path"); MultipartPostMethod method = new MultipartPostMethod(post-file-url); method.addParameter("fileName", file.getName()); method.addPart(new FilePart("file", "file", file)); httpClient.executeMethod(method); String response = method.getResponseBodyAsString();
final Entry entry = this.createActivityEntry(); final RequestOptions options = this.client.getDefaultRequestOptions(); options.setHeader("Content-Type", "multipart/related;type=\"application/atom+xml\""); StringPart entryPart = new StringPart("entry", entry.toString()); entryPart.setContentType("application/atom+xml"); FilePart filePart = new FilePart("file", new File(resource.getFile())); RequestEntity request = new MultipartRequestEntity(new Part[] { entryPart, filePart}, this.client.getHttpClientParams()); ClientResponse response = client.post(this.url + this.activityId, request, options);
HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.yourhost.com"); MultipartEntity entity = new MultipartEntity(); entity.addPart(new StringPart("name", "yourname")); File imageFile = // .. get your image file entity.addPart(new FilePart("picture", imageFile, null, "image/jpeg")); httppost.setEntity(entity); HttpResponse httpResponse = httpclient.execute(httppost);
private FilePart createFilePart(String name, File value) throws FileNotFoundException { FilePart filePart = new FilePart(name, value); filePart.setTransferEncoding(null); filePart.setCharSet(null); return filePart; }
File f = new File("/path/fileToUpload.txt"); HttpRequest request = new HttpRequest("http://host/some_path"); Part[] parts = { new StringPart("param_name", "value"), new FilePart(f.getName(), f) }; filePost.setEntity( new MultipartRequestEntity(parts, filePost.getParams()) ); HttpClient client = new HttpClient(); int status = client.executeMethod(filePost);
File f = new File(filePath); PostMethod filePost = new PostMethod(url); Part[] parts = { new FilePart("file", f) }; filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams())); HttpClient client = new HttpClient(); status = client.executeMethod(filePost);
File f = new File(filePath); PostMethod filePost = new PostMethod(url); Part[] parts = { new FilePart("file", f) }; filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams())); HttpClient client = new HttpClient(); status = client.executeMethod(filePost); logger.info("upload status: " + status);
File f = new File("/path/fileToUpload.txt"); PostMethod filePost = new PostMethod("http://host/some_path"); Part[] parts = { new StringPart("param_name", "value"), new FilePart(f.getName(), f) }; filePost.setRequestEntity( new MultipartRequestEntity(parts, filePost.getParams()) ); HttpClient client = new HttpClient(); int status = client.executeMethod(filePost);
File file = new File("FileToSend.txt"); HttpClient client = new HttpClient(); String url = "http://www.yourdomain.com/destination.php"; PostMethod postMethod = new PostMethod(url); Part[] parts = {new FilePart(file.getName(), file)}; postMethod.setParameter("name", "value"); // set parameters like this instead in separate call postMethod.setRequestEntity( new MultipartRequestEntity(parts, postMethod.getParams())); int status = client.executeMethod(postMethod);
File f = new File("/path/fileToUpload.txt"); PostMethod filePost = new PostMethod("http://host/some_path"); Part[] parts = { new StringPart("param_name", "value"), new FilePart(f.getName(), f) }; filePost.setRequestEntity( new MultipartRequestEntity(parts, filePost.getParams()) ); HttpClient client = new HttpClient(); int status = client.executeMethod(filePost);
File f = new File(filePath); PostMethod postMessage = new PostMethod(urlString); Part[] parts = { new StringPart("param", "value"), new FilePart(f.getName(), f) }; postMessage.setRequestEntity(new MultipartRequestEntity(parts, postMessage.getParams())); HttpClient client = new HttpClient(); int status = client.executeMethod(postMessage);
File f = new File("/path/fileToUpload.txt"); PostMethod filePost = new PostMethod("http://host/some_path"); Part[] parts = { new StringPart("param_name", "value"), new FilePart(f.getName(), f) }; filePost.setRequestEntity( new MultipartRequestEntity(parts, filePost.getParams()) ); HttpClient client = new HttpClient(); int status = client.executeMethod(filePost);
@Override void configureRequest(PostMethod method) throws IOException { Part[] parts = new Part[] { new FilePart("bundle", new ByteArrayPartSource("bundle.jar", IOUtils.toByteArray(jarredBundle))) }; method.setRequestEntity(new MultipartRequestEntity(parts, method.getParams())); } }.installBundle();