提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.infra.framework.file.core.local; |
H |
2 |
|
|
3 |
import cn.hutool.core.io.resource.ResourceUtil; |
|
4 |
import cn.hutool.core.util.IdUtil; |
|
5 |
import com.iailab.module.infra.framework.file.core.client.local.LocalFileClient; |
|
6 |
import com.iailab.module.infra.framework.file.core.client.local.LocalFileClientConfig; |
|
7 |
import org.junit.jupiter.api.Disabled; |
|
8 |
import org.junit.jupiter.api.Test; |
|
9 |
|
|
10 |
public class LocalFileClientTest { |
|
11 |
|
|
12 |
@Test |
|
13 |
@Disabled |
|
14 |
public void test() { |
|
15 |
// 创建客户端 |
|
16 |
LocalFileClientConfig config = new LocalFileClientConfig(); |
|
17 |
config.setDomain("http://127.0.0.1:48080"); |
|
18 |
config.setBasePath("/Users/yunai/file_test"); |
|
19 |
LocalFileClient client = new LocalFileClient(0L, config); |
|
20 |
client.init(); |
|
21 |
// 上传文件 |
|
22 |
String path = IdUtil.fastSimpleUUID() + ".jpg"; |
|
23 |
byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); |
|
24 |
String fullPath = client.upload(content, path, "image/jpeg"); |
|
25 |
System.out.println("访问地址:" + fullPath); |
|
26 |
client.delete(path); |
|
27 |
} |
|
28 |
|
|
29 |
} |