Java tutorial
//package com.java2s; import java.io.File; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.FileEntity; public class Main { /** * Method to initialize and prepare an HttpPost object * @param file * @param url * @param chunked * @return HttpPost */ public static HttpPost prepareRequest(File file, String url, boolean chunked) { HttpPost post = new HttpPost(url); FileEntity reqEntity = new FileEntity(file, "binary/octet-stream"); reqEntity.setContentType("binary/octet-stream"); reqEntity.setChunked(chunked); post.setEntity(reqEntity); return post; } }