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

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


        HttpMultipart multipart = new HttpMultipart("form-data");
        multipart.setParent(message);
        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new FileBody(tmpfile, "test-file", "text/plain", "ANSI_X3.4-1968"));
        FormBodyPart p3 = new FormBodyPart(
                "field3",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));

        multipart.addBodyPart(p1);
View Full Code Here


        HttpPost uploadRequest = new HttpPost(uploadUri);
        try {

            // Now upload file with multipart POST request
            MultipartEntity multipartEntity = new MultipartEntity();
            multipartEntity.addPart(filename, new FileBody(cacheFile));
            uploadRequest.setEntity(multipartEntity);
            HttpResponse uploadResponse = httpClient.execute(uploadRequest);
            if (uploadResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
                logUploadDoesNotEndWithHttpOkStatus(uploadResponse);
                return null;
View Full Code Here

        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httppost = new HttpPost("http://localhost:8080" +
                    "/servlets-examples/servlet/RequestInfoExample");

            FileBody bin = new FileBody(new File(args[0]));
            StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN);

            HttpEntity reqEntity = MultipartEntityBuilder.create()
                    .addPart("bin", bin)
                    .addPart("comment", comment)
View Full Code Here

                }
            });

            multipartEntity.addPart("fid", new StringBody("123456"));
            multipartEntity.addPart("session", new StringBody(authentication.getSession()));
            multipartEntity.addPart("file", new FileBody(artifactFile));
            totalSize = multipartEntity.getContentLength();

            URI uri = URIUtils.createURI(getShema(), getApiJelastic(), getPort(), getUrlUploader(), null, null);
            getLog().debug(uri.toString());
            HttpPost httpPost = new HttpPost(uri);
View Full Code Here

              Object content = p.getParams().get(key);
              if (content != null) {
                if (content instanceof String)
                  entity.addPart(key, new StringBody((String) content));
                else if (content instanceof File)
                  entity.addPart(key, new FileBody((File) content));
              }
            }
          ((HttpPost) e).setEntity(entity);
          debug(e, ha, a);
          HttpResponse res = client.execute(e);
View Full Code Here

      throw new IOException("PDF file does not exist");
    }

    HttpPost request = new HttpPost(uri + "/post/create/" + systemID);

    FileBody bin1 = new FileBody(xml, "application/xml; charset=\"UTF-8\"");
    FileBody bin2 = new FileBody(pdf);
    MultipartEntity requestEntity = new MultipartEntity();
    requestEntity.addPart("xml", bin1);
    requestEntity.addPart("prefilled-pdf", bin2);
    request.setEntity(requestEntity);
View Full Code Here

    }
   
    HttpPost request = new HttpPost(uri + "/post/structure");

    MultipartEntity requestEntity = new MultipartEntity();
    FileBody bin1 = new FileBody(formStructure, "application/xml; charset=\"UTF-8\"");
    FileBody bin2 = null;
    requestEntity.addPart("xml", bin1);
    if (javascript != null) {
      bin2 = new FileBody(javascript, "text/javascript; charset=\"UTF-8\"");
      requestEntity.addPart("js", bin2);
    }
     
    request.setEntity(requestEntity);
       
View Full Code Here

        return response;
    }

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

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

     */
    public InputStream attachFile(String appId, String fileToUpload, String comment, String type) throws CodeSlapException {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(mApiUrl + ApiConstants.METHOD_ATTACHMENTS + ".xml");

        FileBody bin = new FileBody(new File(fileToUpload));
        try {
            MultipartEntity reqEntity = new MultipartEntity();
            reqEntity.addPart("attachment[file]", bin);
            reqEntity.addPart("attachment[app_id]", new StringBody(appId));
            reqEntity.addPart("attachment[comment]", new StringBody(comment));
View Full Code Here

        HttpClient httpclient = new DefaultHttpClient();

        HttpPost httppost = new HttpPost("http://localhost:8080" +
                "/servlets-examples/servlet/RequestInfoExample");

        FileBody bin = new FileBody(new File(args[0]));
        StringBody comment = new StringBody("A binary file of some kind");

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("bin", bin);
        reqEntity.addPart("comment", comment);
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.