Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王飞
vehicle-quality-review
Commits
a817d8c0
Commit
a817d8c0
authored
Jul 04, 2024
by
wdy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调用接口
parent
c783e662
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
TestDownload.java
ruoyi-admin/src/test/java/com/ruoyi/TestDownload.java
+47
-0
No files found.
ruoyi-admin/src/test/java/com/ruoyi/TestDownload.java
0 → 100644
View file @
a817d8c0
package
com
.
ruoyi
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson2.JSONObject
;
import
org.junit.jupiter.api.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
TestDownload
{
@Test
public
void
test
()
{
try
{
// 直接使用URL作为POST请求的目标,假设所有需要的信息已包含在URL中
HttpResponse
response
=
HttpRequest
.
post
(
"https://10.12.48.78:8090/api/project/download"
+
"/fd40de37-9c57-4597-8f74-d0754dfa17b2"
)
// 如果需要添加特定的请求头,如认证信息,可以在这里添加
//.header("Authorization", "Bearer your_token_here")
.
execute
();
// 检查响应是否成功
if
(
response
.
isOk
())
{
System
.
out
.
println
(
"response = "
+
response
);
// 获取文件名,这里简化处理,实际情况可能需要从响应头中解析(如Content-Disposition)
// String fileName = "downloaded_file_from_post.zip";
//
// // 保存到本地
// FileUtil.writeBytes(IoUtil.readBytes(response.bodyStream()), FileUtil.file(fileName));
//
// System.out.println("文件下载成功:" + fileName);
}
else
{
System
.
err
.
println
(
"下载失败,状态码:"
+
response
.
getStatus
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
//以post形式请求接口
// String result= HttpUtil.post("https://10.12.48.78:8090/api/project/download","/fd40de37-9c57-4597-8f74-d0754dfa17b2");
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment