修改文件上传测试用例

This commit is contained in:
阿沐 2022-08-24 11:07:46 +08:00
parent 3780948332
commit 0852fce564
2 changed files with 57 additions and 53 deletions

View File

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>net.maku</groupId> <groupId>net.maku</groupId>
<artifactId>fast-boot</artifactId> <artifactId>fast-boot</artifactId>

View File

@ -1,7 +1,7 @@
package net.maku; package net.maku;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import net.maku.api.module.storage.StorageService; import net.maku.storage.service.StorageService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -15,9 +15,12 @@ public class FileUploadTest {
private StorageService storageService; private StorageService storageService;
@Test @Test
public void uploadTest() throws Exception{ public void uploadTest() throws Exception {
byte[] data = IoUtil.readBytes(Files.newInputStream(new File("D://upload//1.png").toPath())); File file = new File("D://upload//1.png");
String url = storageService.uploadSuffix(data, "png"); byte[] data = IoUtil.readBytes(Files.newInputStream(file.toPath()));
String path = storageService.getPath(file.getName());
String url = storageService.upload(data, path);
System.out.println(url); System.out.println(url);
} }