From 46911b2d954fb8952cc178aa388d977d52d69927 Mon Sep 17 00:00:00 2001 From: E1ED922C1E9526DD63272D7EC5C6CB77 <E1ED922C1E9526DD63272D7EC5C6CB77@i-search.com.cn> Date: 星期日, 07 二月 2021 09:10:08 +0800 Subject: [PATCH] 添加通用文件上传 --- .idea/inspectionProfiles/Project_Default.xml | 2 .idea/libraries/Maven__com_dtflys_forest_forest_spring_1_5_0_RC2.xml | 13 +++ .idea/libraries/Maven__org_apache_httpcomponents_httpcore_nio_4_4_13.xml | 13 +++ .idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_14_9.xml | 13 +++ .idea/libraries/Maven__org_apache_httpcomponents_httpclient_cache_4_5_12.xml | 13 +++ .idea/libraries/Maven__com_squareup_okio_okio_1_17_2.xml | 13 +++ pom.xml | 6 + .idea/libraries/Maven__com_dtflys_forest_spring_boot_starter_forest_1_5_0_RC2.xml | 13 +++ .idea/libraries/Maven__org_apache_httpcomponents_httpasyncclient_4_1_4.xml | 13 +++ .idea/libraries/Maven__org_apache_httpcomponents_httpmime_4_5_12.xml | 13 +++ .idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml | 13 +++ src/main/java/com/hx/util/HttpUtil.java | 42 ++++++++++ .idea/libraries/Maven__com_dtflys_forest_forest_core_1_5_0_RC2.xml | 13 +++ .idea/libraries/Maven__com_googlecode_juniversalchardet_juniversalchardet_1_0_3.xml | 13 +++ hx-common.iml | 15 +++ .idea/libraries/Maven__org_springframework_boot_spring_boot_configuration_processor_2_0_5_RELEASE.xml | 13 +++ 16 files changed, 219 insertions(+), 2 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index f3983d9..2a35e5b 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -3,7 +3,7 @@ <option name="myName" value="Project Default" /> <inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true"> <Languages> - <language minSize="146" name="Java" /> + <language minSize="158" name="Java" /> </Languages> </inspection_tool> </profile> diff --git a/.idea/libraries/Maven__com_dtflys_forest_forest_core_1_5_0_RC2.xml b/.idea/libraries/Maven__com_dtflys_forest_forest_core_1_5_0_RC2.xml new file mode 100644 index 0000000..4d4d8b8 --- /dev/null +++ b/.idea/libraries/Maven__com_dtflys_forest_forest_core_1_5_0_RC2.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.dtflys.forest:forest-core:1.5.0-RC2"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/forest-core/1.5.0-RC2/forest-core-1.5.0-RC2.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/forest-core/1.5.0-RC2/forest-core-1.5.0-RC2-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/forest-core/1.5.0-RC2/forest-core-1.5.0-RC2-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__com_dtflys_forest_forest_spring_1_5_0_RC2.xml b/.idea/libraries/Maven__com_dtflys_forest_forest_spring_1_5_0_RC2.xml new file mode 100644 index 0000000..9d04f1f --- /dev/null +++ b/.idea/libraries/Maven__com_dtflys_forest_forest_spring_1_5_0_RC2.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.dtflys.forest:forest-spring:1.5.0-RC2"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/forest-spring/1.5.0-RC2/forest-spring-1.5.0-RC2.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/forest-spring/1.5.0-RC2/forest-spring-1.5.0-RC2-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/forest-spring/1.5.0-RC2/forest-spring-1.5.0-RC2-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__com_dtflys_forest_spring_boot_starter_forest_1_5_0_RC2.xml b/.idea/libraries/Maven__com_dtflys_forest_spring_boot_starter_forest_1_5_0_RC2.xml new file mode 100644 index 0000000..bb64375 --- /dev/null +++ b/.idea/libraries/Maven__com_dtflys_forest_spring_boot_starter_forest_1_5_0_RC2.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.dtflys.forest:spring-boot-starter-forest:1.5.0-RC2"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/spring-boot-starter-forest/1.5.0-RC2/spring-boot-starter-forest-1.5.0-RC2.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/spring-boot-starter-forest/1.5.0-RC2/spring-boot-starter-forest-1.5.0-RC2-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/dtflys/forest/spring-boot-starter-forest/1.5.0-RC2/spring-boot-starter-forest-1.5.0-RC2-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml new file mode 100644 index 0000000..09453c9 --- /dev/null +++ b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.google.code.findbugs:jsr305:3.0.1"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__com_googlecode_juniversalchardet_juniversalchardet_1_0_3.xml b/.idea/libraries/Maven__com_googlecode_juniversalchardet_juniversalchardet_1_0_3.xml new file mode 100644 index 0000000..b127443 --- /dev/null +++ b/.idea/libraries/Maven__com_googlecode_juniversalchardet_juniversalchardet_1_0_3.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.googlecode.juniversalchardet:juniversalchardet:1.0.3"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_14_9.xml b/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_14_9.xml new file mode 100644 index 0000000..c7878f4 --- /dev/null +++ b/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_14_9.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.squareup.okhttp3:okhttp:3.14.9"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__com_squareup_okio_okio_1_17_2.xml b/.idea/libraries/Maven__com_squareup_okio_okio_1_17_2.xml new file mode 100644 index 0000000..9260035 --- /dev/null +++ b/.idea/libraries/Maven__com_squareup_okio_okio_1_17_2.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: com.squareup.okio:okio:1.17.2"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/com/squareup/okio/okio/1.17.2/okio-1.17.2.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/com/squareup/okio/okio/1.17.2/okio-1.17.2-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/com/squareup/okio/okio/1.17.2/okio-1.17.2-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpasyncclient_4_1_4.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpasyncclient_4_1_4.xml new file mode 100644 index 0000000..fe2908c --- /dev/null +++ b/.idea/libraries/Maven__org_apache_httpcomponents_httpasyncclient_4_1_4.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_cache_4_5_12.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_cache_4_5_12.xml new file mode 100644 index 0000000..d7ecea4 --- /dev/null +++ b/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_cache_4_5_12.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: org.apache.httpcomponents:httpclient-cache:4.5.12"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient-cache/4.5.12/httpclient-cache-4.5.12.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient-cache/4.5.12/httpclient-cache-4.5.12-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient-cache/4.5.12/httpclient-cache-4.5.12-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_nio_4_4_13.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_nio_4_4_13.xml new file mode 100644 index 0000000..6650fe0 --- /dev/null +++ b/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_nio_4_4_13.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.13"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore-nio/4.4.13/httpcore-nio-4.4.13.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore-nio/4.4.13/httpcore-nio-4.4.13-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore-nio/4.4.13/httpcore-nio-4.4.13-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpmime_4_5_12.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpmime_4_5_12.xml new file mode 100644 index 0000000..c1e61ad --- /dev/null +++ b/.idea/libraries/Maven__org_apache_httpcomponents_httpmime_4_5_12.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: org.apache.httpcomponents:httpmime:4.5.12"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.12/httpmime-4.5.12.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.12/httpmime-4.5.12-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.12/httpmime-4.5.12-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_configuration_processor_2_0_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_configuration_processor_2_0_5_RELEASE.xml new file mode 100644 index 0000000..2261ecb --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_configuration_processor_2_0_5_RELEASE.xml @@ -0,0 +1,13 @@ +<component name="libraryTable"> + <library name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.0.5.RELEASE"> + <CLASSES> + <root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-configuration-processor/2.0.5.RELEASE/spring-boot-configuration-processor-2.0.5.RELEASE.jar!/" /> + </CLASSES> + <JAVADOC> + <root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-configuration-processor/2.0.5.RELEASE/spring-boot-configuration-processor-2.0.5.RELEASE-javadoc.jar!/" /> + </JAVADOC> + <SOURCES> + <root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-configuration-processor/2.0.5.RELEASE/spring-boot-configuration-processor-2.0.5.RELEASE-sources.jar!/" /> + </SOURCES> + </library> +</component> \ No newline at end of file diff --git a/hx-common.iml b/hx-common.iml index 1348670..c68fa87 100644 --- a/hx-common.iml +++ b/hx-common.iml @@ -20,12 +20,12 @@ <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="Maven: com.qcloud:cos_api:5.6.32" level="project" /> + <orderEntry type="library" name="Maven: com.qcloud:cos_api:5.6.24" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.6" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" /> - <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" /> <orderEntry type="library" name="Maven: com.sun.mail:javax.mail:1.6.2" level="project" /> <orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-csv:1.6" level="project" /> @@ -107,5 +107,18 @@ <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.11" level="project" /> <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" /> + <orderEntry type="library" name="Maven: com.dtflys.forest:spring-boot-starter-forest:1.5.0-RC2" level="project" /> + <orderEntry type="library" name="Maven: com.dtflys.forest:forest-core:1.5.0-RC2" level="project" /> + <orderEntry type="library" name="Maven: com.googlecode.juniversalchardet:juniversalchardet:1.0.3" level="project" /> + <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient-cache:4.5.12" level="project" /> + <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.12" level="project" /> + <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.13" level="project" /> + <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" /> + <orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.14.9" level="project" /> + <orderEntry type="library" name="Maven: com.squareup.okio:okio:1.17.2" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.1" level="project" /> + <orderEntry type="library" name="Maven: com.dtflys.forest:forest-spring:1.5.0-RC2" level="project" /> + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.0.5.RELEASE" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" /> </component> </module> \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1be7491..ab59e4d 100644 --- a/pom.xml +++ b/pom.xml @@ -249,6 +249,12 @@ <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> + + <dependency> + <groupId>com.dtflys.forest</groupId> + <artifactId>spring-boot-starter-forest</artifactId> + <version>1.5.0-RC2</version> + </dependency> </dependencies> <build> diff --git a/src/main/java/com/hx/util/HttpUtil.java b/src/main/java/com/hx/util/HttpUtil.java index 3222ba1..a043cf0 100644 --- a/src/main/java/com/hx/util/HttpUtil.java +++ b/src/main/java/com/hx/util/HttpUtil.java @@ -162,6 +162,48 @@ return result; } + /** + * 甯eader鐨刧et璇锋眰 + * @param generalUrl + * @param header + * @return + * @throws Exception + */ + public static String get(String generalUrl, Map<String, String> header) + throws Exception { + URL url = new URL(generalUrl); + // 鎵撳紑鍜孶RL涔嬮棿鐨勮繛鎺� + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + // 璁剧疆閫氱敤鐨勮姹傚睘鎬� + connection.setRequestProperty("Connection", "Keep-Alive"); + if(header != null) + { + for(String key : header.keySet()) + { + connection.setRequestProperty(key, header.get(key)); + } + } + + connection.setUseCaches(false); + connection.setDoOutput(true); + connection.setDoInput(true); + + // 寤虹珛瀹為檯鐨勮繛鎺� + connection.connect(); + // 瀹氫箟 BufferedReader杈撳叆娴佹潵璇诲彇URL鐨勫搷搴� + BufferedReader in = null; + in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); + String result = ""; + String getLine; + while ((getLine = in.readLine()) != null) { + result += getLine; + } + in.close(); + + return result; + } + /** 璇锋眰http鍗忚 鑾峰彇淇℃伅宸ュ叿 **/ public static JSONObject HttpURLUtil(String url, String data) { HttpURLConnection con = null; -- Gitblit v1.8.0