|
@@ -10,6 +10,7 @@ import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
|
|
|
import cn.com.qmth.examcloud.web.filestorage.FileStorageType;
|
|
|
import cn.com.qmth.examcloud.web.filestorage.FileStorageUtil;
|
|
|
import cn.com.qmth.examcloud.web.filestorage.YunHttpRequest;
|
|
|
+import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
import cn.com.qmth.examcloud.web.upyun.UpYunClient;
|
|
|
import cn.com.qmth.examcloud.web.upyun.UpYunHttpRequest;
|
|
|
import cn.com.qmth.examcloud.web.upyun.UpYunPathInfo;
|
|
@@ -25,13 +26,17 @@ public class UpyunFileStorageImpl implements FileStorage {
|
|
|
private UpyunService upyunService;
|
|
|
|
|
|
@Override
|
|
|
- public String saveFile(File file, String path) {
|
|
|
+ public YunPathInfo saveFile(File file, String path) {
|
|
|
String siteId="transPath";
|
|
|
UpyunPathEnvironmentInfo env = new UpyunPathEnvironmentInfo();
|
|
|
env.setRelativePath(path);
|
|
|
String fpath = upyunService.writeFile(siteId, env, file, null).getRelativePath();
|
|
|
UpyunSite site=UpyunSiteManager.getUpyunSite(siteId);
|
|
|
- return FileStorageType.UPYUN+"-"+site.getUpyunId()+"://"+fpath;
|
|
|
+ UpYunClient c=UpyunSiteManager.getUpYunClientByUpyunId(site.getUpyunId());
|
|
|
+ String relativePath=FileStorageType.UPYUN+"-"+site.getUpyunId()+"://"+fpath;
|
|
|
+ String url=FileStorageUtil.getUrl(c.getDomain(), fpath);
|
|
|
+ YunPathInfo pi=new YunPathInfo(url, relativePath);
|
|
|
+ return pi;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -42,10 +47,14 @@ public class UpyunFileStorageImpl implements FileStorage {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String saveFile(String siteId, FileStoragePathEnvInfo env, File file) {
|
|
|
- UpYunPathInfo pathInfo =upyunService.writeFile(siteId, of(env), file, null);
|
|
|
+ public YunPathInfo saveFile(String siteId, FileStoragePathEnvInfo env, File file,String md5) {
|
|
|
+ UpYunPathInfo pathInfo =upyunService.writeFile(siteId, of(env), file, md5);
|
|
|
UpyunSite site=UpyunSiteManager.getUpyunSite(siteId);
|
|
|
- return FileStorageType.UPYUN+"-"+site.getUpyunId()+"://"+pathInfo.getRelativePath();
|
|
|
+ String relativePath=FileStorageType.UPYUN+"-"+site.getUpyunId()+"://"+pathInfo.getRelativePath();
|
|
|
+ UpYunClient c=UpyunSiteManager.getUpYunClientByUpyunId(site.getUpyunId());
|
|
|
+ String url=FileStorageUtil.getUrl(c.getDomain(), pathInfo.getRelativePath());
|
|
|
+ YunPathInfo pi=new YunPathInfo(url, relativePath);
|
|
|
+ return pi;
|
|
|
}
|
|
|
|
|
|
private UpyunPathEnvironmentInfo of(FileStoragePathEnvInfo env) {
|