|
@@ -4,7 +4,8 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
import cn.com.qmth.examcloud.support.fss.FssProperty;
|
|
import cn.com.qmth.examcloud.support.fss.FssProperty;
|
|
import cn.com.qmth.examcloud.support.fss.FssService;
|
|
import cn.com.qmth.examcloud.support.fss.FssService;
|
|
-import cn.com.qmth.examcloud.support.fss.model.FileInfo;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.support.fss.model.FssFileInfo;
|
|
|
|
+import cn.com.qmth.examcloud.support.fss.model.FssSignInfo;
|
|
import com.qcloud.cos.COSClient;
|
|
import com.qcloud.cos.COSClient;
|
|
import com.qcloud.cos.ClientConfig;
|
|
import com.qcloud.cos.ClientConfig;
|
|
import com.qcloud.cos.auth.BasicCOSCredentials;
|
|
import com.qcloud.cos.auth.BasicCOSCredentials;
|
|
@@ -29,7 +30,7 @@ public class TencentCosService implements FssService {
|
|
private static final Logger log = LoggerFactory.getLogger(TencentCosService.class);
|
|
private static final Logger log = LoggerFactory.getLogger(TencentCosService.class);
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public FileInfo writeFile(String filePath, File file, String md5) {
|
|
|
|
|
|
+ public FssFileInfo writeFile(String filePath, File file, String md5) {
|
|
if (file == null) {
|
|
if (file == null) {
|
|
throw new StatusException("文件不能为空!");
|
|
throw new StatusException("文件不能为空!");
|
|
}
|
|
}
|
|
@@ -66,7 +67,7 @@ public class TencentCosService implements FssService {
|
|
}
|
|
}
|
|
|
|
|
|
filePath = FssProperty.FSS_SEPARATOR + filePath;
|
|
filePath = FssProperty.FSS_SEPARATOR + filePath;
|
|
- FileInfo result = new FileInfo();
|
|
|
|
|
|
+ FssFileInfo result = new FssFileInfo();
|
|
result.setFileName(FssHelper.getFileName(filePath));
|
|
result.setFileName(FssHelper.getFileName(filePath));
|
|
result.setFilePath(filePath);
|
|
result.setFilePath(filePath);
|
|
result.setFileUrl(FssProperty.FSS_URL_PREFIX + filePath);
|
|
result.setFileUrl(FssProperty.FSS_URL_PREFIX + filePath);
|
|
@@ -74,7 +75,7 @@ public class TencentCosService implements FssService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public FileInfo writeFile(String filePath, byte[] bytes, String md5) {
|
|
|
|
|
|
+ public FssFileInfo writeFile(String filePath, byte[] bytes, String md5) {
|
|
if (StringUtils.isNotEmpty(md5)) {
|
|
if (StringUtils.isNotEmpty(md5)) {
|
|
String realMd5 = FssHelper.getFileMD5(bytes);
|
|
String realMd5 = FssHelper.getFileMD5(bytes);
|
|
if (!md5.equals(realMd5)) {
|
|
if (!md5.equals(realMd5)) {
|
|
@@ -103,7 +104,7 @@ public class TencentCosService implements FssService {
|
|
}
|
|
}
|
|
|
|
|
|
filePath = FssProperty.FSS_SEPARATOR + filePath;
|
|
filePath = FssProperty.FSS_SEPARATOR + filePath;
|
|
- FileInfo result = new FileInfo();
|
|
|
|
|
|
+ FssFileInfo result = new FssFileInfo();
|
|
result.setFileName(FssHelper.getFileName(filePath));
|
|
result.setFileName(FssHelper.getFileName(filePath));
|
|
result.setFilePath(filePath);
|
|
result.setFilePath(filePath);
|
|
result.setFileUrl(FssProperty.FSS_URL_PREFIX + filePath);
|
|
result.setFileUrl(FssProperty.FSS_URL_PREFIX + filePath);
|
|
@@ -196,6 +197,11 @@ public class TencentCosService implements FssService {
|
|
// @see https://cloud.tencent.com/document/product/436/45597
|
|
// @see https://cloud.tencent.com/document/product/436/45597
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public FssSignInfo buildSign(String filePath) {
|
|
|
|
+ return new FssSignInfo();
|
|
|
|
+ }
|
|
|
|
+
|
|
private COSClient getClient() {
|
|
private COSClient getClient() {
|
|
try {
|
|
try {
|
|
Region region = new Region(FssProperty.FSS_REGION_ID);
|
|
Region region = new Region(FssProperty.FSS_REGION_ID);
|