文件下载测试
This commit is contained in:
parent
b3a8c14b33
commit
9a7486617b
@ -0,0 +1,34 @@
|
|||||||
|
package cd.casic.server;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||||
|
import cd.casic.ci.process.process.service.report.ReportService;
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@SpringBootTest(classes = {OpsServerApplication.class})
|
||||||
|
@ActiveProfiles("local")
|
||||||
|
public class FileDownLoadTest {
|
||||||
|
// "D:\博彦科技-项目相关\ops-pro\ops-server\src\main\resources"
|
||||||
|
@Resource
|
||||||
|
private ReportService reportService;
|
||||||
|
@Test
|
||||||
|
public void test01() throws Exception {
|
||||||
|
BaseIdReq baseIdReq = new BaseIdReq();
|
||||||
|
ArrayList<Integer> ids = new ArrayList<>(3);
|
||||||
|
ids.add(28);
|
||||||
|
baseIdReq.setReportIds(ids);
|
||||||
|
ResponseEntity<String> response = reportService.downLoadReport(baseIdReq);
|
||||||
|
byte[] bytes = Base64.decode(response.getBody());
|
||||||
|
File file = new File("D:/博彦科技-项目相关/ops-pro/ops-server/src/main/resources/test.xlsx");
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
fos.write(bytes);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user