本文整理汇总了Java中org.apache.commons.httpclient.methods.multipart.PartBase类的典型用法代码示例。如果您正苦于以下问题:Java PartBase类的具体用法?Java PartBase怎么用?Java PartBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PartBase类属于org.apache.commons.httpclient.methods.multipart包,在下文中一共展示了PartBase类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExtractivProcessString
import org.apache.commons.httpclient.methods.multipart.PartBase; //导入依赖的package包/类
private static PostMethod getExtractivProcessString(
final URI extractivURI,
final String content,
final String serviceKey) throws FileNotFoundException
{
final PartBase filePart = new StringPart("content", content, null);
// bytes to upload
final ArrayList<Part> message = new ArrayList<Part>();
message.add(filePart);
message.add(new StringPart("formids", "content"));
message.add(new StringPart("output_format", "JSON"));
message.add(new StringPart("api_key", serviceKey));
final Part[] messageArray = message.toArray(new Part[0]);
// Use a Post for the file upload
final PostMethod postMethod = new PostMethod(extractivURI.toString());
postMethod.setRequestEntity(new MultipartRequestEntity(messageArray, postMethod.getParams()));
postMethod.addRequestHeader("Accept-Encoding", "gzip"); // Request the response be compressed (this is highly recommended)
return postMethod;
}