|
@@ -1,7 +1,8 @@
|
|
|
-package com.zheng.oss.web.controller;
|
|
|
|
|
|
|
+package com.zheng.oss.web.controller;
|
|
|
|
|
|
|
|
import com.aliyun.oss.OSSClient;
|
|
import com.aliyun.oss.OSSClient;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
+import com.zheng.oss.rpc.api.OssApiService;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.ModelMap;
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -11,20 +12,23 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Created by shuzheng on 2016/11/12.
|
|
|
|
|
|
|
+ * Created by shuzheng on 2017/4/18.
|
|
|
*/
|
|
*/
|
|
|
@Controller
|
|
@Controller
|
|
|
-@RequestMapping("/app")
|
|
|
|
|
-public class AppController {
|
|
|
|
|
|
|
+@RequestMapping("/demo")
|
|
|
|
|
+public class DemoController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OssApiService ossApiService;
|
|
|
|
|
|
|
|
@RequestMapping(value = "/index", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/index", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public String index(ModelMap modelMap) {
|
|
public String index(ModelMap modelMap) {
|
|
|
// endpoint以杭州为例,其它region请按实际情况填写
|
|
// endpoint以杭州为例,其它region请按实际情况填写
|
|
|
- String endpoint = "";
|
|
|
|
|
|
|
+ String endpoint = "oss-cn-shanghai.aliyuncs.com";
|
|
|
// accessKey请登录https://ak-console.aliyun.com/#/查看
|
|
// accessKey请登录https://ak-console.aliyun.com/#/查看
|
|
|
- String accessKeyId = "";
|
|
|
|
|
- String accessKeySecret = "";
|
|
|
|
|
|
|
+ String accessKeyId = "LTAIf5dDIthJN3h0";
|
|
|
|
|
+ String accessKeySecret = "2IZVHc1Qzxul8rC0ZQGKCEjjnpvm5d";
|
|
|
|
|
|
|
|
// 创建OSSClient实例
|
|
// 创建OSSClient实例
|
|
|
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
|
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
|
@@ -35,6 +39,7 @@ public class AppController {
|
|
|
|
|
|
|
|
// 关闭ossClient
|
|
// 关闭ossClient
|
|
|
ossClient.shutdown();
|
|
ossClient.shutdown();
|
|
|
|
|
+
|
|
|
return "success";
|
|
return "success";
|
|
|
}
|
|
}
|
|
|
|
|
|