Package org.apache.http.entity

Examples of org.apache.http.entity.FileEntity


            }
            String contenttype = null;
            if (cmd.hasOption('T')) {
                contenttype = cmd.getOptionValue('T');
            }
            FileEntity entity = new FileEntity(file, contenttype);
            if (file.length() > 100000) {
                entity.setChunked(true);
            }
            HttpPost httppost = new HttpPost(url.getPath());
            httppost.setEntity(entity);
            request = httppost;
        } else if (cmd.hasOption('i')) {
View Full Code Here


        throws ClientServicesException {
     
      Object contents = args.getHandler();
        if(contents instanceof File){
            String name = args.getParameters().get("file");
            FileEntity fileEnt = new FileEntity((File) contents, getMimeForUpload());
            //fileEnt.setContentEncoding(FORMAT_BINARY);
            httpRequestBase.setHeader("slug", name);
            httpRequestBase.setHeader("Content-type", getMimeForUpload());
            if (fileEnt != null && (httpRequestBase instanceof HttpEntityEnclosingRequestBase)) {
                ((HttpEntityEnclosingRequestBase) httpRequestBase).setEntity(fileEnt);
View Full Code Here

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

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

        HttpPost post = new HttpPost(providerURI);
        post.addHeader("Content-Type", "image/gif");
        post.addHeader("Title", "Title " + receiptName + "");
        post.addHeader("Slug", "Slug " + receiptName + "");

        post.setEntity(new FileEntity(input, "image/gif"));

        // Get HTTP client
        org.apache.http.client.HttpClient httpclient = new HttpClientFactory().createHttpClient();
        try {
            // Execute request
View Full Code Here

        // ...binary data...
        HttpPut put = new HttpPut(providerURI + "/" + mediaId);
        put.addHeader("Content-Type", "image/jpg");
        put.addHeader("Title", "Title " + receiptName + "");
        put.addHeader("Slug", "Slug " + receiptName + "");
        put.setEntity(new FileEntity(input, "image/jpg"));

        // Get HTTP client
        HttpClient httpclient = new HttpClientFactory().createHttpClient();
        try {
            // Execute request
View Full Code Here

        // ...binary data...
        HttpPut put = new HttpPut(providerURI + "/" + mediaId + "-bogus"); // Does not exist.
        put.addHeader("Content-Type", "image/jpg");
        put.addHeader("Title", "Title " + receiptName + "");
        put.addHeader("Slug", "Slug " + receiptName + "");
        put.setEntity(new FileEntity(input, "image/jpg"));

        // Get HTTP client
        HttpClient httpclient = new HttpClientFactory().createHttpClient();
        try {
            // Execute 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

                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

                    // file based (could potentially also be a FTP file etc)
                    if (data instanceof File || data instanceof GenericFile) {
                        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

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.