|
|
@@ -10,7 +10,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
@@ -23,9 +22,8 @@ import java.util.UUID;
|
|
|
@DubboService
|
|
|
@Service
|
|
|
public class FileServiceImpl implements FileService {
|
|
|
- private PutObjectService putObjectService;
|
|
|
+ private final PutObjectService putObjectService;
|
|
|
private final FileMetaMapper fileMetaMapper;
|
|
|
- private final int pageSize = 10;
|
|
|
|
|
|
public FileServiceImpl(PutObjectService putObjectService, FileMetaMapper fileMetaMapper) {
|
|
|
this.fileMetaMapper = fileMetaMapper;
|
|
|
@@ -45,9 +43,9 @@ public class FileServiceImpl implements FileService {
|
|
|
public void createDirectory(String pid, String filename) {
|
|
|
String filename1 = checkFilename(pid, filename);
|
|
|
String fileId = UUID.randomUUID().toString().replace("-", "");
|
|
|
- String objectName = "";
|
|
|
- FileMeta fileMeta = new FileMeta(pid, fileId, objectName, filename1);
|
|
|
- //fileMetaMapper.save(fileInfo);
|
|
|
+ String objectName = String.format("disk/0/1/%s/", fileId);
|
|
|
+ FileMeta fileMeta = new FileMeta(objectName, fileId, filename1, pid);
|
|
|
+ fileMetaMapper.save(fileMeta);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -55,8 +53,7 @@ public class FileServiceImpl implements FileService {
|
|
|
String fileId = UUID.randomUUID().toString().replace("-", "");
|
|
|
String objectName = "";
|
|
|
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
|
|
|
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
|
|
- //putObjectService.putObject(objectName, bais, bytes.length);
|
|
|
+ putObjectService.putObject(objectName, bytes);
|
|
|
return fileId;
|
|
|
}
|
|
|
|