|
|
@@ -1,12 +1,17 @@
|
|
|
package com.zheng.oss.web.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.oss.OSSClient;
|
|
|
import com.aliyun.oss.model.OSSObject;
|
|
|
import com.aliyun.oss.model.PutObjectResult;
|
|
|
+import com.zheng.common.base.BaseController;
|
|
|
import com.zheng.oss.common.constant.OssConstant;
|
|
|
+import com.zheng.oss.web.service.AliyunOssService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -17,12 +22,15 @@ import java.io.*;
|
|
|
* oss测试
|
|
|
* Created by shuzheng on 2017/4/18.
|
|
|
*/
|
|
|
-@RestController
|
|
|
+@Controller
|
|
|
@RequestMapping("/demo")
|
|
|
-public class DemoController {
|
|
|
+public class DemoController extends BaseController {
|
|
|
|
|
|
private static Logger _log = LoggerFactory.getLogger(DemoController.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AliyunOssService aliyunOssService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private OSSClient aliyunOssClient;
|
|
|
|
|
|
@@ -61,4 +69,13 @@ public class DemoController {
|
|
|
return "http://" + OssConstant.ALIYUN_OSS_BUCKET_NAME + "." + OssConstant.ALIYUN_OSS_ENDPOINT + "/file.png";
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/aliyun/upload")
|
|
|
+ public String upload(Model model) {
|
|
|
+ JSONObject policy = aliyunOssService.policy();
|
|
|
+ _log.info("policy={}", policy);
|
|
|
+ model.addAttribute("policy", policy);
|
|
|
+ model.addAttribute("policy", policy);
|
|
|
+ return thymeleaf("/aliyun/upload");
|
|
|
+ }
|
|
|
+
|
|
|
}
|