Package org.apache.http.entity.mime.content

Examples of org.apache.http.entity.mime.content.FileBody


    public static void postFile(String fileName, String mhttpgw)
        throws ClientProtocolException, IOException {
      HttpClient client = new DefaultHttpClient();
      HttpPost post = new HttpPost(mhttpgw);
      MultipartEntity entity = new MultipartEntity();
      entity.addPart("file", new FileBody(new File(fileName)));
      post.setEntity(entity);
      HttpResponse response = client.execute(post);

    }
View Full Code Here


  public static void postFile(String fileName)
                    throws ClientProtocolException, IOException {
            HttpClient client = new DefaultHttpClient();
            HttpPost post = new HttpPost("http://10.1.1.203:1337");
            MultipartEntity entity = new MultipartEntity();
            entity.addPart("file", new FileBody(new File(fileName)));
            post.setEntity(entity);
            HttpResponse response = client.execute(post);

    }
View Full Code Here

  public static void postFile(String fileName)
                    throws ClientProtocolException, IOException {
            HttpClient client = new DefaultHttpClient();
            HttpPost post = new HttpPost("http://10.1.1.203:1337");
            MultipartEntity entity = new MultipartEntity();
            entity.addPart("file", new FileBody(new File(fileName)));
            post.setEntity(entity);
            HttpResponse response = client.execute(post);

    }
View Full Code Here

  public static void postFile(String fileName)
                    throws ClientProtocolException, IOException {
            HttpClient client = new DefaultHttpClient();
            HttpPost post = new HttpPost("http://10.1.1.203:1337");
            MultipartEntity entity = new MultipartEntity();
            entity.addPart("file", new FileBody(new File(fileName)));
            post.setEntity(entity);
            HttpResponse response = client.execute(post);

    }
View Full Code Here

    public static void postFile(String fileName, String mhttpgw)
        throws ClientProtocolException, IOException {
      HttpClient client = new DefaultHttpClient();
      HttpPost post = new HttpPost(mhttpgw);
      MultipartEntity entity = new MultipartEntity();
      entity.addPart("file", new FileBody(new File(fileName)));
      post.setEntity(entity);
      HttpResponse response = client.execute(post);

    }
View Full Code Here

          String submissionXmlFileName = subName + File.separator + subName + "_submission_"+d+".xml";

          File subtmp = new File(submissionStoragePath + submissionXmlFileName);
          SubmissionUtils.transform(submissionXml, subtmp, true);

          reqEntity.addPart("SUBMISSION", new FileBody(subtmp));
          for (String key : map.keySet()) {
            List<Submittable<Document>> submittables = map.get(key);
            String submittableXmlFileName = subName
                                            + File.separator
                                            + subName
                                            + "_"
                                            + key.toLowerCase()
                                            + "_"
                                            + d
                                            + ".xml";
            File elementTmp = new File(submissionStoragePath + submittableXmlFileName);
            Document submissionDocument = docBuilder.newDocument();
            ERASubmissionFactory.generateSubmissionXML(submissionDocument, submittables, key, submissionProperties);
            SubmissionUtils.transform(submissionDocument, elementTmp, true);
            reqEntity.addPart(key.toUpperCase(), new FileBody(elementTmp));
          }

          httppost.setEntity(reqEntity);
          HttpResponse response = httpclient.execute(httppost);
View Full Code Here

        return response;
    }

    protected Response makePostUploadRequest(URI uri, File fileToUpload, String paramName)
            throws Exception {
        FileBody fileBodyToUpload = new FileBody(fileToUpload);

        docTest.sayUploadRequest(uri, HTTP_REQUEST.POST, fileBodyToUpload.getFilename(), fileHelper
                .readFile(fileToUpload), fileToUpload.length());
        apiTest.setPostFactory(new PostUploadWithoutRedirectImpl(paramName, fileBodyToUpload));
        Response response = new Response(apiTest.post(uri, null));
        docTest.sayResponse(response.httpStatus, response.payload);
View Full Code Here

                  File f = Play.application().getFile(nvpFile.getName());
                  if (f == null)
                  {
                    assertFail("Cannot find file <" + nvpFile.getName() + ">");
                  }
                  FileBody fb = new FileBody(f);
                  out.writeBytes("Content-Disposition: form-data; name=\"" + PARAM_FILE + "\";filename=\"" + fb.getFilename() + "\"\r\n");
                  out.writeBytes("Content-Type: " + nvpFile.getValue() + "\r\n\r\n");
                  out.write(getResource(nvpFile.getName()));
                }
                out.writeBytes("\r\n--" + BOUNDARY + "--\r\n");
              }
View Full Code Here

    multipartEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

    File file = new File("small");
    URL small = new URL(VideoURLs.map.get("small-webm"));
    FileUtils.copyURLToFile(small, file);
    FileBody fb = new FileBody(file);
    multipartEntity.addPart("file", fb);

    HttpEntity httpEntity = multipartEntity.build();
    post.setEntity(httpEntity);
View Full Code Here

        }

        HttpMultipart multipart = new HttpMultipart("form-data", "foo");
        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));

        multipart.addBodyPart(p1);
View Full Code Here

TOP

Related Classes of org.apache.http.entity.mime.content.FileBody

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.