Package org.apache.http.entity

Examples of org.apache.http.entity.FileEntity


                    System.out.println("Cannot read file " + file.getPath());

                } else {

                    response.setStatusCode(HttpStatus.SC_OK);
                    FileEntity body = new FileEntity(file, "text/html");
                    response.setEntity(body);
                    System.out.println("Serving file " + file.getPath());

                }
            }
View Full Code Here


                    System.out.println("Cannot read file " + file.getPath());

                } else {

                    response.setStatusCode(HttpStatus.SC_OK);
                    FileEntity body = new FileEntity(file, "text/html");
                    response.setEntity(body);
                    System.out.println("Serving file " + file.getPath());

                }
            }
View Full Code Here

      this(name, content, APPLICATION_OCTET_STREAM);
    }

    @Override
    public HttpEntity createEntity() throws ClientServicesException {
      FileEntity fileEnt = new FileEntity(content, getContentType());
      fileEnt.setContentEncoding(BINARY); // Is that OK?
      return fileEnt;
    }
View Full Code Here

                    else {
                        post.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
                    }
                }

                FileEntity fileRequestEntity = new FileEntity(new File(file.getPath()),(ContentType) null);// TODO is null correct?
                post.setEntity(fileRequestEntity);

                // We just add placeholder text for file content
                postedBody.append("<actual file content, not shown here>");
            } else {
View Full Code Here

        if(!hasArguments() && getSendFileAsPostBody()) {
            hasEntityBody = true;

            // If getSendFileAsPostBody returned true, it's sure that file is not null
            FileEntity fileRequestEntity = new FileEntity(new File(files[0].getPath())); // no need for content-type here
            entity.setEntity(fileRequestEntity);
        }
        // If none of the arguments have a name specified, we
        // just send all the values as the entity body
        else if(getSendParameterValuesAsPostBody()) {
View Full Code Here

    protected abstract T process(
            HttpResponse response, File file, ContentType contentType) throws Exception;

    @Override
    protected T buildResult(final HttpContext context) throws Exception {
        final FileEntity entity = new FileEntity(this.file);
        entity.setContentType(this.response.getFirstHeader(HTTP.CONTENT_TYPE));
        this.response.setEntity(entity);
        return process(this.response, this.file, this.contentType);
    }
View Full Code Here

                }
            } finally {
                instream.close();
            }
            if (ok) {
                FileEntity responseEntity = new FileEntity(TEST_FILE, "text/plian");
                if (this.forceChunking) {
                    responseEntity.setChunked(true);
                }
                response.setEntity(responseEntity);
            } else {
                response.setEntity(new StringEntity("Invalid content"));
            }
View Full Code Here

                        answer = entity;
                    } else if (data instanceof File || data instanceof GenericFile) {
                        // file based (could potentially also be a FTP file etc)
                        File file = in.getBody(File.class);
                        if (file != null) {
                            answer = new FileEntity(file, contentType);
                        }
                    } else if (data instanceof String) {
                        // be a bit careful with String as any type can most likely be converted to String
                        // so we only do an instanceof check and accept String if the body is really a String
                        // do not fallback to use the default charset as it can influence the request
View Full Code Here

                        answer = entity;
                    } else if (data instanceof File || data instanceof GenericFile) {
                        // file based (could potentially also be a FTP file etc)
                        File file = in.getBody(File.class);
                        if (file != null) {
                            answer = new FileEntity(file, contentType);
                        }
                    } else if (data instanceof String) {
                        // be a bit careful with String as any type can most likely be converted to String
                        // so we only do an instanceof check and accept String if the body is really a String
                        // do not fallback to use the default charset as it can influence the request
View Full Code Here

                    else {
                        post.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
                    }
                }

                FileEntity fileRequestEntity = new FileEntity(new File(file.getPath()),(ContentType) null);// TODO is null correct?
                post.setEntity(fileRequestEntity);

                // We just add placeholder text for file content
                postedBody.append("<actual file content, not shown here>");
            } else {
View Full Code Here

TOP

Related Classes of org.apache.http.entity.FileEntity

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.