Example usage for org.apache.http.entity FileEntity toString

List of usage examples for org.apache.http.entity FileEntity toString

Introduction

In this page you can find the example usage for org.apache.http.entity FileEntity toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.spokenpic.net.RestClientFilePost.java

@Override
protected RestResult doPost() {
    HttpPost httpPost = new HttpPost(getSchemeServer() + this.uri);
    setupHttp(httpPost);/*from  ww w.ja v a2  s  .c om*/
    try {
        FileEntity e = new FileEntity(new File(data), mime);
        httpPost.setEntity(e);

        HttpResponse httpResponse = HttpManager.execute(httpPost);
        return returnResponse(httpResponse);
    } catch (Exception e) {
        Log.d("RestClientFilePost", "Error doPost " + e.toString());
        return errorResponse("Fatal error during file POST");
    }
}

From source file:com.buffalokiwi.api.API.java

/**
 * Perform a post-based request to some endpoint
 * @param url URL/*from   w  ww.  ja  va2  s . com*/
 * @param file A file to post 
 * @param headers additional headers to send
 * @return response
 * @throws APIException
 */
@Override
public IAPIResponse post(final String url, final PostFile file, Map<String, String> headers)
        throws APIException {
    final FileEntity entity = new FileEntity(file.getFile(), file.getContentType());
    if (file.hasContentEncoding())
        entity.setContentEncoding(file.getContentEncoding());

    final HttpPost post = (HttpPost) createRequest(HttpMethod.POST, url, headers);
    post.setEntity(entity);
    APILog.trace(LOG, entity.toString());

    return executeRequest(post);

}

From source file:com.buffalokiwi.api.API.java

/**
 * Perform a put-based request to some endpoint
 * @param url URL/*  www.  ja v  a2s.c o m*/
 * @param file file to send 
 * @param headers additional headers 
 * @return response 
 * @throws APIException 
 */
@Override
public IAPIResponse put(final String url, final PostFile file, Map<String, String> headers)
        throws APIException {
    final FileEntity entity = new FileEntity(file.getFile(), file.getContentType());
    if (file.hasContentEncoding())
        entity.setContentEncoding(file.getContentEncoding());

    //..Create the new put request
    final HttpPut put = (HttpPut) createRequest(HttpMethod.PUT, url, headers);

    //..Set the put payload
    put.setEntity(entity);

    APILog.trace(LOG, entity.toString());

    //..Execute the request
    return executeRequest(put);

}

From source file:com.buffalokiwi.api.API.java

/**
 * Perform a patch-based request to some endpoint
 * @param url URL//from   w ww.  j a  va 2  s.co m
 * @param file file to send 
 * @param headers additional headers 
 * @return response 
 * @throws APIException 
 */
@Override
public IAPIResponse patch(final String url, final PostFile file, Map<String, String> headers)
        throws APIException {
    final FileEntity entity = new FileEntity(file.getFile(), file.getContentType());
    if (file.hasContentEncoding())
        entity.setContentEncoding(file.getContentEncoding());

    //..Create the new patch request
    final HttpPatch patch = (HttpPatch) createRequest(HttpMethod.PUT, url, headers);

    //..Set the patch payload
    patch.setEntity(entity);

    APILog.trace(LOG, entity.toString());

    //..Execute the request
    return executeRequest(patch);

}