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


        final URL url = config.getUrl();
        HttpEntity entity = null;

        // Prepare requests for each thread
        if (config.getPayloadFile() != null) {
            final FileEntity fe = new FileEntity(config.getPayloadFile());
            fe.setContentType(config.getContentType());
            fe.setChunked(config.isUseChunking());
            entity = fe;
        } else if (config.getPayloadText() != null) {
            final StringEntity se = new StringEntity(config.getPayloadText(),
                    ContentType.parse(config.getContentType()));
            se.setChunked(config.isUseChunking());
View Full Code Here

          HttpPost request = new HttpPost( uri.build() );
          HttpEntity entity = null;
          if( text != null ) {
            entity = new StringEntity( text, ContentType.create( "application/xml", "UTF-8" ) );
          } else if( file != null ) {
            entity = new FileEntity( new File( file ), ContentType.create( "application/xml" ) );
          }
          request.setEntity( entity );
          return new Response( execute( request ) );
        }
      };
View Full Code Here

          HttpPut dn = new HttpPut( loc );
          HttpEntity e = null;
          if( text != null ) {
            e = new StringEntity( text );
          } else if( file != null ) {
            e = new FileEntity( new File( file ) );
          }
          dn.setEntity( e );
          return new Response( execute( dn ) );
        }
      };
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

                StringEntity body = new StringEntity("Access Denied", "UTF-8");
                response.setEntity(body);
                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

    public void uploadFile(String uri, File sourceFile, String contentType) throws IOException {
        String path = getPath(uri);

        HttpPut request = (HttpPut) setupRequest(path, PUT, null);
        request.setEntity(contentType == null ? new FileEntity(sourceFile) : new FileEntity(sourceFile, ContentType.parse(contentType)));

        performRequest(request);
    }
View Full Code Here

          HttpPut dn = new HttpPut( loc );
          HttpEntity e = null;
          if( text != null ) {
            e = new StringEntity( text );
          } else if( file != null ) {
            e = new FileEntity( new File( file ) );
          }
          dn.setEntity( e );
          return new Response( execute( dn ) );
        }
      };
View Full Code Here

          HttpPost request = new HttpPost( uri.build() );
          HttpEntity entity = null;
          if( text != null ) {
            entity = new StringEntity( text, ContentType.create( "application/xml", "UTF-8" ) );
          } else if( file != null ) {
            entity = new FileEntity( new File( file ), ContentType.create( "application/xml" ) );
          }
          request.setEntity( entity );
          return new Response( execute( request ) );
        }
      };
View Full Code Here

    public Request bodyString(final String s, final ContentType contentType) {
        return body(new StringEntity(s, contentType));
    }

    public Request bodyFile(final File file, final ContentType contentType) {
        return body(new FileEntity(file, contentType));
    }
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.