|
|
@@ -15,10 +15,9 @@ import com.zhongshu.card.server.core.model.upLoadFile.*;
|
|
|
import com.zhongshu.card.server.core.model.upLoadFile.oss.ALiObjectStorage;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
@@ -57,7 +56,8 @@ public class NetDiskOssBusService extends SuperService {
|
|
|
String fileName = param.getFileName();
|
|
|
List<String[]> allPaths = buildPathByUser(param.getFileNames(), user);
|
|
|
Collection<String[]> paths = allPaths.parallelStream().map((path) -> {
|
|
|
- return this.toPlatformFileStoreObjectPath(user, path, isReserveName, fileName);
|
|
|
+ String _fileName = path[(path.length - 1)];
|
|
|
+ return this.toPlatformFileStoreObjectPath(user, path, isReserveName, _fileName);
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
remoteFile.setAccountId(param.getOid());
|
|
|
@@ -81,6 +81,14 @@ public class NetDiskOssBusService extends SuperService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public ResultContent<List<FileStoreModel>> uploadFinishMuli(FileItemModel[] fileItems) {
|
|
|
+ com.github.microservice.netdisk.client.content.ResultContent<List<FileStoreModel>> content = netDiskOssService.uploadFinish(fileItems);
|
|
|
+ if (content.getState() == com.github.microservice.netdisk.client.content.ResultState.Success) {
|
|
|
+ return ResultContent.buildSuccess(content.getContent());
|
|
|
+ } else {
|
|
|
+ return ResultContent.buildFail(content.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public ResultContent<StsToken> getUploadToken(RemoteBusFile remoteFile) {
|
|
|
// PathAssert.validate(remoteFile.getPath());
|
|
|
@@ -97,6 +105,7 @@ public class NetDiskOssBusService extends SuperService {
|
|
|
// 获取三方持久化对象
|
|
|
// final SuperObjectStorageStore objectStorageStore = this.objectStorageStore.getObjectStorageStore(account.getId());
|
|
|
Collection<String[]> paths = allPaths.parallelStream().map((path) -> {
|
|
|
+ String _fileName = path[(path.length - 1)];
|
|
|
return this.toPlatformFileStoreObjectPath(user, path, isReserveName, fileName);
|
|
|
}).collect(Collectors.toList());
|
|
|
StsToken stsToken = aliObjectStorageStore.getStsToken(paths);
|
|
|
@@ -113,7 +122,11 @@ public class NetDiskOssBusService extends SuperService {
|
|
|
public String[] buildUploadFilePathFromLatestVersion(final UserAccount account, String[] sourcePath, Boolean isReserveName, String fileName) {
|
|
|
//文件版本号
|
|
|
final Long fileVersionNumber = 1L;
|
|
|
- return PlatformFileItem.builder().accountId(account.getId()) //账户
|
|
|
+ String countId = "file";
|
|
|
+ if (ObjectUtils.isNotEmpty(account)) {
|
|
|
+ countId = account.getId();
|
|
|
+ }
|
|
|
+ return PlatformFileItem.builder().accountId(countId) //账户
|
|
|
.versionNumber(fileVersionNumber)//版本
|
|
|
.platformStoreType(PlatformStoreType.Store) //类型
|
|
|
.sourcePath(sourcePath)//原路径
|
|
|
@@ -122,9 +135,15 @@ public class NetDiskOssBusService extends SuperService {
|
|
|
|
|
|
public List<String[]> buildPathByUser(RemoteBusFile param, UserAccount user) {
|
|
|
List<String[]> paths = new ArrayList<>();
|
|
|
+ String userId;
|
|
|
+ if (ObjectUtils.isNotEmpty(user)) {
|
|
|
+ userId = user.getId();
|
|
|
+ } else {
|
|
|
+ userId = "file";
|
|
|
+ }
|
|
|
param.getFileNames().forEach(it -> {
|
|
|
String[] split = it.split("\\.");
|
|
|
- List<String> path = Lists.newArrayList(new String[]{user.getId(), UUID.randomUUID().toString() + "." + split[1]});
|
|
|
+ List<String> path = Lists.newArrayList(new String[]{userId, UUID.randomUUID().toString() + "." + split[1]});
|
|
|
paths.add(path.toArray(new String[0]));
|
|
|
});
|
|
|
return paths;
|
|
|
@@ -134,7 +153,12 @@ public class NetDiskOssBusService extends SuperService {
|
|
|
List<String[]> paths = new ArrayList<>();
|
|
|
fileNames.forEach(it -> {
|
|
|
String[] split = it.split("\\.");
|
|
|
- List<String> path = Lists.newArrayList(new String[]{user.getId(), UUID.randomUUID().toString() + "." + split[1]});
|
|
|
+ List<String> path = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(user)) {
|
|
|
+ path = Lists.newArrayList(new String[]{user.getId(), UUID.randomUUID().toString() + "." + split[1]});
|
|
|
+ } else {
|
|
|
+ path = Lists.newArrayList(new String[]{UUID.randomUUID().toString() + "." + split[1]});
|
|
|
+ }
|
|
|
paths.add(path.toArray(new String[0]));
|
|
|
});
|
|
|
return paths;
|