use of org.apache.commons.httpclient.methods.InputStreamRequestEntity in project zm-mailbox by Zimbra.
the class UserServlet method putMailItem.
public static Pair<Header[], HttpInputStream> putMailItem(ZAuthToken authToken, String url, MailItem item) throws ServiceException, IOException {
if (item instanceof Document) {
Document doc = (Document) item;
StringBuilder u = new StringBuilder(url);
u.append("?").append(QP_AUTH).append('=').append(AUTH_COOKIE);
if (doc.getType() == MailItem.Type.WIKI) {
u.append("&fmt=wiki");
}
PutMethod method = new PutMethod(u.toString());
String contentType = doc.getContentType();
method.addRequestHeader("Content-Type", contentType);
method.setRequestEntity(new InputStreamRequestEntity(doc.getContentStream(), doc.getSize(), contentType));
method = HttpClientUtil.addInputStreamToHttpMethod(method, doc.getContentStream(), doc.getSize(), contentType);
method.addRequestHeader("X-Zimbra-Description", doc.getDescription());
method.setRequestEntity(new InputStreamRequestEntity(doc.getContentStream(), doc.getSize(), contentType));
Pair<Header[], HttpMethod> pair = doHttpOp(authToken, method);
return new Pair<Header[], HttpInputStream>(pair.getFirst(), new HttpInputStream(pair.getSecond()));
}
return putRemoteResource(authToken, url, item.getContentStream(), null);
}
use of org.apache.commons.httpclient.methods.InputStreamRequestEntity in project sling by apache.
the class SlingIntegrationTestClient method upload.
/** Upload a file to the Sling repository
* @return the HTTP status code
*/
public int upload(String toUrl, InputStream is) throws IOException {
final PutMethod put = new PutMethod(toUrl);
put.setRequestEntity(new InputStreamRequestEntity(is));
return httpClient.executeMethod(put);
}
Aggregations