Merge branch 'dev_2.0.0_test' into dev_2.0.0

dev_2.0.0
xueqingkun 1 year ago
commit b7a2236cef

@ -30,7 +30,7 @@ public class MinioUtil {
*
*/
public static String uploadFile(InputStream stream, String objectName) throws Exception {
ObjectWriteResponse objectWriteResponse = minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(objectName)
ObjectWriteResponse objectWriteResponse = minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(objectName).contentType("video/mp4")
.stream(stream, -1, 10485760).build());
return objectWriteResponse.object();
}

@ -57,6 +57,36 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

@ -0,0 +1,124 @@
package com.supervision;
import cn.hutool.core.io.FileUtil;
import com.supervision.config.MinioProperties;
import com.supervision.model.FileResource;
import com.supervision.service.FileResourceService;
import com.supervision.util.MinioUtil;
import io.minio.MinioClient;
import io.minio.StatObjectArgs;
import io.minio.StatObjectResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.BufferedInputStream;
import java.io.File;
import java.util.HashMap;
import java.util.UUID;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringJUnit4ClassRunner.class)
public class VideoUpdateTest {
@Autowired
private FileResourceService fileResourceService;
@Autowired
private MinioProperties minioProperties;
@Autowired
private MinioClient minioClient;
@Test
public void contextLoads() throws Exception {
String m = "1 你好,医生\n" +
"2 我最近感觉心跳特别快,喘不上气。\n" +
"3 感觉心跳特别快,喘不上气,活动后更严重\n" +
"4 比较严重\n" +
"5 觉得手抖、怕热,容易出汗,胃口很好,吃很多还总觉得饿,紧张,特别容易发脾气,还拉肚子,瘦了一些\n" +
"6 最近半年吧\n" +
"7 夏天很怕热,晚上也会睡不着\n" +
"8 活动后会加重,双腿还会没劲\n" +
"9 影响到我的工作和生活了\n" +
"10 没有注意到\n" +
"11 我不知道\n" +
"12 头痛,发烧\n" +
"13 感觉是全头疼\n" +
"14 基本上天天出现\n" +
"15 似乎是比之前掉的多了\n" +
"16 是的我每天大约3次稀便\n" +
"17 之前没有\n" +
"18 体力好像比之前差了一些,最近这些天我经常喘不过气来,并且活动后感觉双腿乏力,感觉到非常虚弱\n" +
"19 没有\n" +
"20 之前身体很好,没吃过什么药\n" +
"21 胃口很好,总感觉饿\n" +
"22 主要是尿多,口干,喝水也多\n" +
"23 大约有三个月\n" +
"24 老是觉得饿,比以前吃得多,人反而瘦了\n" +
"25 是的\n" +
"26 次数多了,特别是晚上以前从来不起夜现在要起来3、4次\n" +
"27 3个月瘦了7kg\n" +
"28 没有了\n" +
"29 还可以\n" +
"30 5年前得过胆结石把胆囊切掉了。\n" +
"31 一直都比较正常。\n" +
"32 有,对青霉素过敏。\n" +
"33 是高中时,因扁桃体化脓,医生本来要给用青霉素,但做了皮试是阳性。\n" +
"34 应该做过,记不清了。\n" +
"35 喜欢抽烟,10多年了每天1包\n" +
"36 我母亲身体不太好50岁得时候体检发现有糖尿病一直在吃药。\n" +
"37 天气寒冷时酸痛症状可加重,热敷可缓解\n" +
"38 正常\n" +
"39 腹部偶尔也会觉得疼痛\n" +
"40 说不清楚\n" +
"41 正常不闷,晚上睡觉向左侧睡,左胸有时闷。\n" +
"42 没有,有时过饱有胀满感觉\n";
String[] split = m.split("\n");
HashMap<Integer, String> codeMap = new HashMap<>();
for (int i = 0; i < split.length; i++) {
String s = split[i];
String[] split1 = s.split(" ");
System.out.println("---" + split1[0] +"----"+split1[1]);
codeMap.put(Integer.valueOf(split1[0]),split1[1]);
}
// 读取文件 0-41
// 读取文件名 1-42
FileResource fileResource = new FileResource();
fileResource.setFileType("mp4");
for (int i = 0; i < 42; i++) {
fileResource.setFileName(codeMap.get(i+1));
fileResource.setMinioId(UUID.randomUUID().toString());
BufferedInputStream inputStream = FileUtil.getInputStream("F:\\supervision\\doc\\数字人视频\\final_video\\final_video\\"+i+".mp4");
MinioUtil.uploadFile(inputStream, fileResource.getMinioId());
System.out.println("---------------------上传文件:"+fileResource.getFileName());
StatObjectResponse response = minioClient.statObject(StatObjectArgs.builder().bucket(minioProperties.getBucketName()).object(fileResource.getMinioId()).build());
fileResource.setFileSize(Integer.valueOf(String.valueOf(response.size())));
fileResourceService.save(fileResource);
fileResource.setId(null);
}
}
}
Loading…
Cancel
Save