mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
文件上传完成后跳转到文件详情页
This commit is contained in:
@@ -286,13 +286,18 @@ public class FileController extends BaseController {
|
||||
// 判断对象是否存在
|
||||
Boolean isExist = qCloudCosUtils.doesObjectExist(bookSaveFolder, fileSha1);
|
||||
String url = null;
|
||||
Map resultMap = new HashMap();
|
||||
resultMap.put("guid", urlGUID);
|
||||
switch (httpMethodName) {
|
||||
case PUT:
|
||||
// 上传文件
|
||||
if (isExist) throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "文件已存在");
|
||||
|
||||
fileObjectService.uploadFile(fileId, fileName, bookSaveFolder + fileSha1, fileSize,
|
||||
Integer realFileId = fileObjectService.uploadFile(fileId, fileName, bookSaveFolder + fileSha1, fileSize,
|
||||
fileSha1, fileExt, fileName, FileStorageMediumEnum.QCLOUD_COS, "", lastModified);
|
||||
// fileId 可能为 0 (创建新文件)
|
||||
// realFileId 是从数据库中查询出来的,真实的文件id
|
||||
resultMap.put("fileId", realFileId);
|
||||
url = qCloudCosUtils.generatePresignedUrl(userModel.getId(), httpMethodName, bookSaveFolder, fileSha1, expireMinute, urlGUID);
|
||||
break;
|
||||
case GET:
|
||||
@@ -310,10 +315,8 @@ public class FileController extends BaseController {
|
||||
throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "httpMethod 参数暂不支持");
|
||||
}
|
||||
|
||||
Map map = new HashMap();
|
||||
map.put("url", url);
|
||||
map.put("guid", urlGUID);
|
||||
return CommonReturnType.create(map);
|
||||
resultMap.put("url", url);
|
||||
return CommonReturnType.create(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -123,14 +123,14 @@ public class FileObjectServiceImpl implements FileObjectService {
|
||||
* @param fileNameWithoutExt 文件名(不包含扩展名)
|
||||
* @param fileStorageMediumEnum 文件存储介质
|
||||
* @param bookOrigin 文件来源
|
||||
* @return 是否插入成功
|
||||
* @return 返回文件Id
|
||||
* @throws InvocationTargetException
|
||||
* @throws IllegalAccessException
|
||||
* @throws BusinessException
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1,
|
||||
public Integer uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1,
|
||||
String fileExt, String fileNameWithoutExt, FileStorageMediumEnum fileStorageMediumEnum,
|
||||
String bookOrigin, Long lastModified
|
||||
) throws InvocationTargetException, IllegalAccessException, BusinessException {
|
||||
@@ -189,7 +189,7 @@ public class FileObjectServiceImpl implements FileObjectService {
|
||||
if (!isSuccess) {
|
||||
throw new BusinessException(BusinessErrorCode.UNKNOWN_ERROR, "文件对象创建失败");
|
||||
}
|
||||
return true;
|
||||
return fileId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -55,7 +55,7 @@ public interface FileObjectService {
|
||||
* @throws BusinessException
|
||||
*/
|
||||
@Transactional
|
||||
Boolean uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1, String fileExt, String fileNameWithoutExt, FileStorageMediumEnum fileStorageMediumEnum, String bookOrigin, Long lastModified) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
Integer uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1, String fileExt, String fileNameWithoutExt, FileStorageMediumEnum fileStorageMediumEnum, String bookOrigin, Long lastModified) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
|
||||
/**
|
||||
* 修改文件对象上传状态信息
|
||||
|
Reference in New Issue
Block a user