接口文档
package xy.FileSystem.Client;
import xy.FileSystem.File.HttpResult;
import xy.FileSystem.Utils.HttpHelper;
//Post上传演示
public class ClientMultipartFormPost {
public static void main(String[] args) throws Exception {
HttpResult result = HttpHelper.executeUploadFile(HttpHelper.createHttpClient(),
"http://localhost:9091/fileUploadPost", //post路径url
"D://Tigase开发文档.doc", //要上传的本地文件全路径
"1234", // appid
"wangxin", //上传者username
"", //groupid,如果不涉及群组,则无需传此参数
true,//执行请求结束后是否关闭HttpClient客户端实例
"UTF-8" );
System.out.println(result.toString());
}
}
/**
* 执行文件上传
*
* @param httpClient HttpClient客户端实例,传入null会自动创建一个
* @param remoteFileUrl 远程接收文件的地址
* @param localFilePath 本地文件地址
* @param appid 应用id
* @param username 上传者用户名
* @param groupid MUC群组名称,如果是个人文件则无需
* @param charset 请求编码,默认UTF-8
* @param closeHttpClient 执行请求结束后是否关闭HttpClient客户端实例
* @return
* @throws ClientProtocolException
* @throws IOException
*/
public static HttpResult executeUploadFile(CloseableHttpClient httpClient,
String remoteFileUrl,
String localFilePath,
String appid,
String username,
String groupid,
boolean closeHttpClient,
String charset )
......
package xy.FileSystem.Client;
import xy.FileSystem.Utils.HttpHelper;
//下载
public class ClientMultipartFormDownload {
public static void main(String[] args) throws Exception {
HttpHelper.executeDownloadFile(HttpHelper.createHttpClient(),
"http://localhost:9091/files/wangxin_Tigase开发文档.doc", //服务器文件
"D://wangxin_Tigase开发文档.doc", //下载到本地的文件
"UTF-8",
true);
}
}