09-20-2010 06:12 AM
09-24-2010 09:44 AM
public static String doUploadCall(String ticket, Map<String, Object> parameters, UploadFile file, String url)throws HttpException, IOException{
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(url + "?alf_ticket=" + ticket);
method.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
JSONObject json = JSONObject.fromObject(parameters);
File f = new File(file.getFileName());
OutputStream output = new FileOutputStream(f);
IOUtils.copy(file.getInpuStream(), output);
Part[] parts = {
new StringPart("alf_ticket", ticket),
new StringPart("parameters", json.toString()),
new FilePart("file", f)
};
method.setRequestEntity(
new MultipartRequestEntity(parts, method.getParams())
);
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + method.getStatusLine());
}
return method.getResponseBodyAsString();
}
04-11-2011 12:51 PM
public static String doUploadCall(String ticket, Map<String, Object> parameters, UploadFile file, String url)throws HttpException, IOException{
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.