|
@@ -0,0 +1,54 @@
|
|
|
|
+/*
|
|
|
|
+ * *************************************************
|
|
|
|
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
|
|
|
|
+ * Created by Deason on 2018-11-01 17:41:12.
|
|
|
|
+ * *************************************************
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+package cn.com.qmth.examcloud.core.print.test;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.examcloud.core.print.PrintApplication;
|
|
|
|
+import cn.com.qmth.examcloud.core.print.common.upyun.UpYunClient;
|
|
|
|
+import cn.com.qmth.examcloud.core.print.common.utils.FileUtils;
|
|
|
|
+import main.java.com.UpYun;
|
|
|
|
+import org.junit.Test;
|
|
|
|
+import org.junit.runner.RunWith;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
+
|
|
|
|
+import java.io.File;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author: fengdesheng
|
|
|
|
+ * @since: 2018/11/01
|
|
|
|
+ */
|
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
|
+@SpringBootTest(classes = PrintApplication.class)
|
|
|
|
+public class UpYunServiceTest {
|
|
|
|
+ @Autowired
|
|
|
|
+ private UpYunClient upYunClient;
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void demoTest() throws Exception {
|
|
|
|
+ final String dir = "C:/Users/deason/Desktop/";
|
|
|
|
+ final String fileName = "demo.png";
|
|
|
|
+
|
|
|
|
+ final String newFileName = FileUtils.newFileName(fileName);
|
|
|
|
+ final String newFilePath = upYunClient.getProperty().getUploadUrl() + FileUtils.dateDir() + newFileName;
|
|
|
|
+
|
|
|
|
+ UpYun client = upYunClient.getInstance();
|
|
|
|
+
|
|
|
|
+ //上传文件
|
|
|
|
+ File uploadFile = new File(dir + fileName);
|
|
|
|
+ client.writeFile(newFilePath, uploadFile);
|
|
|
|
+
|
|
|
|
+ //下载文件
|
|
|
|
+ File downloadFile = new File(dir + "temp_" + fileName);
|
|
|
|
+ client.readFile(newFilePath, downloadFile);
|
|
|
|
+
|
|
|
|
+ //https://ecs-test-static.qmth.com.cn/ecs-print/test/201811/f02b5abbacb543c59dce9adc16254305.png
|
|
|
|
+ System.out.println(upYunClient.getProperty().getFileUrl() + newFilePath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|