123
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
package com.bashi.dk.controller.app;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.auth.sts.AssumeRoleRequest;
|
||||
import com.aliyuncs.auth.sts.AssumeRoleResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.exceptions.ServerException;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.bashi.common.core.domain.AjaxResult;
|
||||
import com.bashi.dk.manager.FileUploadManager;
|
||||
import com.bashi.dk.manager.FileUploadRes;
|
||||
import com.bashi.dk.oss.ali.StsOssKit;
|
||||
import com.bashi.dk.oss.ali.StsResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.x.file.storage.core.FileInfo;
|
||||
import org.dromara.x.file.storage.core.FileStorageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -17,6 +27,8 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
/**
|
||||
* <p>created on 2021/7/13</p>
|
||||
*
|
||||
* https://help.aliyun.com/zh/oss/developer-reference/use-temporary-access-credentials-provided-by-sts-to-access-oss#p-osc-r0m-u63
|
||||
*
|
||||
* @author zhangliang
|
||||
*/
|
||||
@RestController
|
||||
@@ -26,6 +38,19 @@ public class V2CommonController {
|
||||
@Autowired
|
||||
private FileStorageService fileStorageService;
|
||||
|
||||
@Autowired
|
||||
private StsOssKit stsOssKit;
|
||||
|
||||
@GetMapping("/v2/common/sts")
|
||||
@ApiOperation("文件上传")
|
||||
public AjaxResult getSts(){
|
||||
StsResult stsToken = stsOssKit.getStsToken();
|
||||
if(stsToken == null){
|
||||
return AjaxResult.error(400,"文件上传初始化失败");
|
||||
}
|
||||
return AjaxResult.success(stsToken);
|
||||
}
|
||||
|
||||
@PostMapping("/v2/common/upload")
|
||||
@ApiOperation("文件上传")
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user