"sending a excel file in MultipartEntityBuilder" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "sending a excel file in MultipartEntityBuilder" answered properly. Developers are finding an appropriate answer about sending a excel file in MultipartEntityBuilder related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like sending a excel file in MultipartEntityBuilder. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on sending a excel file in MultipartEntityBuilder.
sending a excel file in MultipartEntityBuilder
private String uploadFile (String filePath, String HTML) throws Exception {
String postUrl = getUploadUrl(HTML);
postUrl = "http://printing.**.ca:9191" + postUrl;
HttpPost post = new HttpPost(postUrl);
HttpClient client = new DefaultHttpClient();
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
String random = "";
Random ran = new Random();
for (int i = 0; i < 28; i++) {
random = random + String.valueOf(ran.nextInt(9));
}
String boundary = "---------------------------" + random;
final File file = new File(filePath);
FileBody fb = new FileBody(file, ContentType.create("application/vnd.ms-excel"), "hello.xls");
builder.addPart("file[];", fb);
builder.setBoundary(boundary);
post.setEntity(builder.build());
post.setHeader("Host", "printing.**.ca:9191");
post.setHeader("User-Agent", USER_AGENT);
post.setHeader("Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
post.setHeader("Accept-Language", "en-US,en;q=0.5");
post.setHeader("Referer",
"http://printing.**.ca:9191/app");
post.setHeader("Connection", "keep-alive");
for (String cookie : this.cookies) {
for (String c : cookie.split(";")) {
if (c.contains("JSESSION")) {
post.setHeader("Cookie", c);
}
}
}
HttpResponse response = client.execute(post);
String reply = sendPost("http://printing.**.ca:9191/app", getUploadParameters(HTML));
return response.toString();
}
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on sending a excel file in MultipartEntityBuilder can get a collection of related answers to their query. Programmers need to enter their query on sending a excel file in MultipartEntityBuilder related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about sending a excel file in MultipartEntityBuilder for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of sending a excel file in MultipartEntityBuilder while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "sending a excel file in MultipartEntityBuilder". Visit this developer's friendly online web community, CodeProZone, and get your queries like sending a excel file in MultipartEntityBuilder resolved professionally and stay updated to the latest Whatever updates.