List of usage examples for org.apache.http.entity FileEntity setContentEncoding
public void setContentEncoding(Header header)
From source file:com.google.resting.method.post.PostServiceContext.java
private HttpEntity setFileEntity(File file, ContentType contentType, EncodingTypes encoding) { FileEntity entity = null; try {// ww w .j a v a2 s . c om entity = new FileEntity(file, contentType.getName()); if (encoding != null) entity.setContentEncoding(encoding.getName()); } catch (Exception e) { e.printStackTrace(); } return entity; }
From source file:com.buffalokiwi.api.API.java
/** * Perform a post-based request to some endpoint * @param url URL//ww w . j a v a 2 s . c o m * @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//from w w w . j av a2 s . 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 ww w .ja va 2s. c om * @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); }
From source file:org.envirocar.app.dao.remote.BaseRemoteDAO.java
protected HttpResponse executePayloadRequest(HttpEntityEnclosingRequestBase request, FileWithMetadata content) throws NotConnectedException, UnauthorizedException, ResourceConflictException { FileEntity entity = new FileEntity(content.getFile(), "application/json"); if (content.isGzipped()) { entity.setContentEncoding("gzip"); }/*from w w w .jav a 2s . c om*/ request.setEntity(entity); return executePayloadRequest(request); }