对外提供文件上传接口
This commit is contained in:
parent
8fe006ef63
commit
3780948332
|
@ -0,0 +1,52 @@
|
|||
package net.maku.api.module.system;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 存储服务API
|
||||
*
|
||||
* @author 阿沐 babamu@126.com
|
||||
*/
|
||||
public interface StorageApi {
|
||||
|
||||
/**
|
||||
* 根据文件名,生成带时间戳的新文件名
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 返回带时间戳的文件名
|
||||
*/
|
||||
String getNewFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 生成路径,不包含文件名
|
||||
*
|
||||
* @return 返回生成的路径
|
||||
*/
|
||||
String getPath();
|
||||
|
||||
/**
|
||||
* 根据文件名,生成路径
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 生成文件路径
|
||||
*/
|
||||
String getPath(String fileName);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param data 文件字节数组
|
||||
* @param path 文件路径,包含文件名
|
||||
* @return 返回http地址
|
||||
*/
|
||||
String upload(byte[] data, String path);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param inputStream 字节流
|
||||
* @param path 文件路径,包含文件名
|
||||
* @return 返回http地址
|
||||
*/
|
||||
String upload(InputStream inputStream, String path);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package net.maku.system.api;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.maku.api.module.system.StorageApi;
|
||||
import net.maku.storage.service.StorageService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 存储服务Api
|
||||
*
|
||||
* @author 阿沐 babamu@126.com
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class StorageApiImpl implements StorageApi {
|
||||
private final StorageService storageService;
|
||||
|
||||
@Override
|
||||
public String getNewFileName(String fileName) {
|
||||
return storageService.getNewFileName(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return storageService.getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath(String fileName) {
|
||||
return storageService.getPath(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(byte[] data, String path) {
|
||||
return storageService.upload(data, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(InputStream inputStream, String path) {
|
||||
return storageService.upload(inputStream, path);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user