|
@@ -36,6 +36,7 @@ import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
|
|
import cn.com.qmth.examcloud.web.filestorage.FileStorageType;
|
|
import cn.com.qmth.examcloud.web.filestorage.FileStorageType;
|
|
import cn.com.qmth.examcloud.web.filestorage.FileStorageUtil;
|
|
import cn.com.qmth.examcloud.web.filestorage.FileStorageUtil;
|
|
import cn.com.qmth.examcloud.web.filestorage.YunHttpRequest;
|
|
import cn.com.qmth.examcloud.web.filestorage.YunHttpRequest;
|
|
|
|
+import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
|
|
|
@Service(value = "aliyunFileStorage")
|
|
@Service(value = "aliyunFileStorage")
|
|
public class AliyunFileStorageImpl implements FileStorage {
|
|
public class AliyunFileStorageImpl implements FileStorage {
|
|
@@ -45,14 +46,17 @@ public class AliyunFileStorageImpl implements FileStorage {
|
|
private static int maxFileSize = 100 * 1024 * 1024;
|
|
private static int maxFileSize = 100 * 1024 * 1024;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String saveFile(File file, String path) {
|
|
|
|
|
|
+ public YunPathInfo saveFile(File file, String path) {
|
|
try {
|
|
try {
|
|
String siteId = "transPath";
|
|
String siteId = "transPath";
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
env.setRelativePath(path);
|
|
env.setRelativePath(path);
|
|
String relativePath = postObject(siteId, env, file, null);
|
|
String relativePath = postObject(siteId, env, file, null);
|
|
AliyunSite as = AliyunSiteManager.getAliyunSite(siteId);
|
|
AliyunSite as = AliyunSiteManager.getAliyunSite(siteId);
|
|
- return FileStorageType.ALIYUN + "-" + as.getAliyunId() + "://" + relativePath;
|
|
|
|
|
|
+ AliYunAccount ac = AliyunSiteManager.getAliYunAccountByAliyunId(as.getAliyunId());
|
|
|
|
+ String url=FileStorageUtil.getUrl(ac.getDomain(), relativePath);
|
|
|
|
+ YunPathInfo pi=new YunPathInfo(url, FileStorageType.ALIYUN + "-" + as.getAliyunId() + "://" + relativePath);
|
|
|
|
+ return pi;
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new StatusException("1001", "上传出错", e);
|
|
throw new StatusException("1001", "上传出错", e);
|
|
}
|
|
}
|
|
@@ -225,11 +229,14 @@ public class AliyunFileStorageImpl implements FileStorage {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String saveFile(String siteId, FileStoragePathEnvInfo env, File file) {
|
|
|
|
|
|
+ public YunPathInfo saveFile(String siteId, FileStoragePathEnvInfo env, File file,String md5) {
|
|
try {
|
|
try {
|
|
String relativePath = postObject(siteId, env, file, null);
|
|
String relativePath = postObject(siteId, env, file, null);
|
|
AliyunSite as = AliyunSiteManager.getAliyunSite(siteId);
|
|
AliyunSite as = AliyunSiteManager.getAliyunSite(siteId);
|
|
- return FileStorageType.ALIYUN + "-" + as.getAliyunId() + "://" + relativePath;
|
|
|
|
|
|
+ AliYunAccount ac = AliyunSiteManager.getAliYunAccountByAliyunId(as.getAliyunId());
|
|
|
|
+ String url=FileStorageUtil.getUrl(ac.getDomain(), relativePath);
|
|
|
|
+ YunPathInfo pi=new YunPathInfo(url, FileStorageType.ALIYUN + "-" + as.getAliyunId() + "://" + relativePath);
|
|
|
|
+ return pi;
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new StatusException("5001", "上传出错", e);
|
|
throw new StatusException("5001", "上传出错", e);
|
|
}
|
|
}
|