|
@@ -0,0 +1,64 @@
|
|
|
+package cn.com.qmth.examcloud.web.upyun;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
+
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
+import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
+import cn.com.qmth.examcloud.commons.util.FreeMarkerUtil;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 类注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @date 2018年9月4日
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class UpyunServiceImpl implements UpyunService {
|
|
|
+
|
|
|
+ protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UpYunPathInfo writeFile(String siteId, UpyunPathEnvironmentInfo env, InputStream in) {
|
|
|
+ env.setCurrentTimeMillis(String.valueOf(System.currentTimeMillis()));
|
|
|
+
|
|
|
+ UpyunSite upyunSite = UpyunSiteManager.getUpyunSite(siteId);
|
|
|
+ UpYunClient upYunClient = UpyunSiteManager.getUpYunClient(siteId);
|
|
|
+
|
|
|
+ String path = FreeMarkerUtil.process(upyunSite.getPath(), env);
|
|
|
+ UpYunPathInfo pathInfo = upYunClient.writeFile(path, in);
|
|
|
+ return pathInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UpYunPathInfo writeFile(String siteId, UpyunPathEnvironmentInfo env, File file) {
|
|
|
+ env.setCurrentTimeMillis(String.valueOf(System.currentTimeMillis()));
|
|
|
+
|
|
|
+ UpyunSite upyunSite = UpyunSiteManager.getUpyunSite(siteId);
|
|
|
+ UpYunClient upYunClient = UpyunSiteManager.getUpYunClient(siteId);
|
|
|
+
|
|
|
+ String path = FreeMarkerUtil.process(upyunSite.getPath(), env);
|
|
|
+ UpYunPathInfo pathInfo = upYunClient.writeFile(path, file);
|
|
|
+ return pathInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(String siteId, String filePath) {
|
|
|
+ UpYunClient upYunClient = UpyunSiteManager.getUpYunClient(siteId);
|
|
|
+ upYunClient.deleteFile(filePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UpYunSign buildUpYunSign(String siteId, UpyunPathEnvironmentInfo env) {
|
|
|
+ UpyunSite upyunSite = UpyunSiteManager.getUpyunSite(siteId);
|
|
|
+ UpYunClient upYunClient = UpyunSiteManager.getUpYunClient(siteId);
|
|
|
+
|
|
|
+ String path = FreeMarkerUtil.process(upyunSite.getPath(), env);
|
|
|
+ UpYunSign sign = upYunClient.buildUpYunSign(path);
|
|
|
+ return sign;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|