Skip to content

Commit

Permalink
Support InputStream type upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed Apr 12, 2024
1 parent b290b8e commit 176df9d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"java.debug.settings.onBuildFailureProceed": true,
"java.configuration.updateBuildConfiguration": "interactive"
"java.debug.settings.onBuildFailureProceed": true
}
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ NOTE: 文档地址: http://gudaoxuri.github.io/dew-common/[http://gudaoxuri.gi
<dependency>
<groupId>com.ecfront.dew</groupId>
<artifactId>common</artifactId>
<version>4.0.0-rc.1</version>
<version>4.0.0-rc.2</version>
</dependency>
----

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<description>Dew公共模块</description>
<url>https://github.com/gudaoxuri/dew-common</url>
<packaging>jar</packaging>
<version>4.0.0-rc.1</version>
<version>4.0.0-rc.2</version>

<properties>
<java.version>21</java.version>
Expand All @@ -36,7 +36,7 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.compilerVersion>${java.version}</maven.compiler.compilerVersion>
<jackson.version>2.15.3</jackson.version>
<jackson.version>2.17.0</jackson.version>
<beanutils.version>1.9.4</beanutils.version>
<jbcrypt.version>0.4</jbcrypt.version>
<slf4j.version>2.0.9</slf4j.version>
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/ecfront/dew/common/HttpHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,7 @@ public ResponseWrap request(String method, String url, Object body, Map<String,
try {
return new FileInputStream(fileBody);
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
throw new RTIOException(e);
}
}, fileBody.getName(), $.mime.getContentType(fileBody));
header.put("Content-Type", "multipart/form-data; boundary=" + publisher.getBoundary());
Expand All @@ -889,6 +888,10 @@ public ResponseWrap request(String method, String url, Object body, Map<String,
entity = HttpRequest.BodyPublishers.ofString(((Date) body).getTime() + "", Charset.forName(requestCharset));
} else if (body instanceof File) {
entity = HttpRequest.BodyPublishers.ofFile(((File) body).toPath());
} else if (body instanceof InputStream) {
entity = HttpRequest.BodyPublishers.fromPublisher(
HttpRequest.BodyPublishers.ofInputStream(() -> (InputStream) body),
((InputStream) body).available());
} else {
entity = HttpRequest.BodyPublishers.ofString($.json.toJsonString(body), Charset.forName(requestCharset));
}
Expand Down

0 comments on commit 176df9d

Please sign in to comment.