Commit 3d0c7bd3222693ededcfa8e3fe3ef4042e3f33f5
1 parent
05245f6c8f
Exists in
master
and in
6 other branches
update
Showing 1 changed file with 76 additions and 23 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java
View file @
3d0c7bd
| 1 | -package com.lyms.platform.operate.web; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.lyms.platform.common.enums.BabySourceEnums; | |
| 5 | -import com.lyms.platform.common.enums.QhdBabyPsychologyEnums; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * Created by Administrator on 2016/8/22 0022. | |
| 9 | - */ | |
| 10 | -public class Test { | |
| 11 | - | |
| 12 | - final static long TIME = 1000 * 90; | |
| 13 | - | |
| 14 | - public static void main(String[] args) throws Exception { | |
| 15 | - | |
| 16 | - } | |
| 17 | - | |
| 18 | - | |
| 19 | - | |
| 20 | - | |
| 21 | -} | |
| 1 | +//package com.lyms.platform.operate.web; | |
| 2 | +// | |
| 3 | +//import org.apache.http.HttpEntity; | |
| 4 | +//import org.apache.http.client.ClientProtocolException; | |
| 5 | +//import org.apache.http.client.config.RequestConfig; | |
| 6 | +//import org.apache.http.client.methods.CloseableHttpResponse; | |
| 7 | +//import org.apache.http.client.methods.HttpPost; | |
| 8 | +//import org.apache.http.entity.ContentType; | |
| 9 | +//import org.apache.http.entity.mime.MultipartEntityBuilder; | |
| 10 | +//import org.apache.http.entity.mime.content.FileBody; | |
| 11 | +//import org.apache.http.entity.mime.content.StringBody; | |
| 12 | +//import org.apache.http.impl.client.CloseableHttpClient; | |
| 13 | +//import org.apache.http.impl.client.HttpClients; | |
| 14 | +//import org.apache.http.util.EntityUtils; | |
| 15 | +// | |
| 16 | +//import java.io.File; | |
| 17 | +//import java.io.IOException; | |
| 18 | +// | |
| 19 | +///** | |
| 20 | +// * Created by Administrator on 2016/8/22 0022. | |
| 21 | +// */ | |
| 22 | +//public class Test { | |
| 23 | +// | |
| 24 | +// final static long TIME = 1000 * 90; | |
| 25 | +// | |
| 26 | +// public static void main(String[] args) throws Exception { | |
| 27 | +// | |
| 28 | +// File dir = new File("F:\\aa"); | |
| 29 | +// File[] files = dir.listFiles(); | |
| 30 | +// for (File file : files) | |
| 31 | +// { | |
| 32 | +// upload("https://cert-qhd-api.healthbaby.com.cn:18020/cp/common/importSignature", file, file.getName()); | |
| 33 | +// Thread.sleep(TIME); | |
| 34 | +// } | |
| 35 | +// } | |
| 36 | +// | |
| 37 | +// | |
| 38 | +// public static void upload(String url,File file,String filename) { | |
| 39 | +// CloseableHttpClient httpclient = HttpClients.createDefault(); | |
| 40 | +// try { | |
| 41 | +// HttpPost httppost = new HttpPost(url); | |
| 42 | +// RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(2000000).setSocketTimeout(2000000).build(); | |
| 43 | +// httppost.setConfig(requestConfig); | |
| 44 | +// FileBody bin = new FileBody(file); | |
| 45 | +// StringBody comment = new StringBody(filename, ContentType.TEXT_PLAIN); | |
| 46 | +// HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("file", bin).addPart("filename", comment).build(); | |
| 47 | +// httppost.setEntity(reqEntity); | |
| 48 | +// httppost.setHeader("Authorization","18674e5b23b200f86a6210ea2f1006a8"); | |
| 49 | +// CloseableHttpResponse response = httpclient.execute(httppost); | |
| 50 | +// try { | |
| 51 | +// System.out.println(response.getStatusLine()); | |
| 52 | +// HttpEntity resEntity = response.getEntity(); | |
| 53 | +// if (resEntity != null) { | |
| 54 | +// String responseEntityStr = EntityUtils.toString(response.getEntity()); | |
| 55 | +// System.out.println(file.getName()+"===="+responseEntityStr); | |
| 56 | +// } | |
| 57 | +// EntityUtils.consume(resEntity); | |
| 58 | +// } finally { | |
| 59 | +// response.close(); | |
| 60 | +// } | |
| 61 | +// } catch (ClientProtocolException e) { | |
| 62 | +// e.printStackTrace(); | |
| 63 | +// } catch (IOException e) { | |
| 64 | +// e.printStackTrace(); | |
| 65 | +// } finally { | |
| 66 | +// try { | |
| 67 | +// httpclient.close(); | |
| 68 | +// } catch (IOException e) { | |
| 69 | +// e.printStackTrace(); | |
| 70 | +// } | |
| 71 | +// } | |
| 72 | +// } | |
| 73 | +// | |
| 74 | +//} | |
| 75 | +// | |
| 76 | +// |