|
@@ -3,31 +3,19 @@ package com.fdkankan.contro.controller;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.amazonaws.HttpMethod;
|
|
|
|
-import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
|
|
|
-import com.amazonaws.auth.BasicAWSCredentials;
|
|
|
|
-import com.amazonaws.regions.Regions;
|
|
|
|
-import com.amazonaws.services.s3.AmazonS3;
|
|
|
|
-import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
|
|
|
-import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
|
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.contro.common.Result;
|
|
import com.fdkankan.contro.common.Result;
|
|
import com.fdkankan.contro.service.ISceneFileBuildService;
|
|
import com.fdkankan.contro.service.ISceneFileBuildService;
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
-import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.net.URL;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -44,11 +32,9 @@ public class SceneFileController{
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneFileBuildService sceneFileBuildService;
|
|
private ISceneFileBuildService sceneFileBuildService;
|
|
|
|
|
|
- @Autowired(required = false)
|
|
|
|
- private AmazonS3 amazonS3;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private FYunFileConfig fileConfig;
|
|
|
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 场景文件上传之前先获取fileId
|
|
* 场景文件上传之前先获取fileId
|
|
@@ -108,6 +94,8 @@ public class SceneFileController{
|
|
if(files == null){
|
|
if(files == null){
|
|
throw new BusinessException(ErrorCode.PARAM_ERROR,"params为空。");
|
|
throw new BusinessException(ErrorCode.PARAM_ERROR,"params为空。");
|
|
}
|
|
}
|
|
|
|
+ //生成预签名URL
|
|
|
|
+ log.info("生成预签名URL");
|
|
List<String> urls = new ArrayList<>();
|
|
List<String> urls = new ArrayList<>();
|
|
for(int i = 0, len = files.size(); i < len; i++){
|
|
for(int i = 0, len = files.size(); i < len; i++){
|
|
urls.add(files.getJSONObject(i).getString("filename"));
|
|
urls.add(files.getJSONObject(i).getString("filename"));
|
|
@@ -119,22 +107,9 @@ public class SceneFileController{
|
|
if(urls == null || urls.size() <= 0){
|
|
if(urls == null || urls.size() <= 0){
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- java.util.Date expiration = new java.util.Date();
|
|
|
|
- long expTimeMillis = expiration.getTime();
|
|
|
|
- expTimeMillis += 1000 * 60 * 60 * 8;
|
|
|
|
- expiration.setTime(expTimeMillis);
|
|
|
|
-
|
|
|
|
- //生成预签名URL
|
|
|
|
- log.info("生成预签名URL");
|
|
|
|
- GeneratePresignedUrlRequest generatePresignedUrlRequest = null;
|
|
|
|
- URL url = null;
|
|
|
|
Map<String, String> map = new HashMap();
|
|
Map<String, String> map = new HashMap();
|
|
for(String path : urls){
|
|
for(String path : urls){
|
|
- generatePresignedUrlRequest = new GeneratePresignedUrlRequest(fileConfig.getBucket(), path)
|
|
|
|
- .withMethod(HttpMethod.PUT)
|
|
|
|
- .withExpiration(expiration);
|
|
|
|
- url = amazonS3.generatePresignedUrl(generatePresignedUrlRequest);
|
|
|
|
- map.put(path, url.toString());
|
|
|
|
|
|
+ map.put(path, fYunFileService.getPresignedUrl(path).toString());
|
|
}
|
|
}
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|