|
@@ -1,13 +1,25 @@
|
|
|
package com.fdkankan.scene.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
+import com.obs.services.ObsClient;
|
|
|
+import com.obs.services.internal.utils.Mimetypes;
|
|
|
+import com.obs.services.model.AccessControlList;
|
|
|
+import com.obs.services.model.ObjectMetadata;
|
|
|
+import com.obs.services.model.PutObjectRequest;
|
|
|
+import org.apache.http.HttpHeaders;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.activation.MimeType;
|
|
|
+import java.io.File;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* TODO
|
|
@@ -27,7 +39,36 @@ public class TestController {
|
|
|
|
|
|
@GetMapping("/test")
|
|
|
public ResultData test(){
|
|
|
- return ResultData.ok(fYunFileService.fileExist("scene_result_data/KK-t-JCaoqtvy7AO/caches/images"));
|
|
|
+ //obsv3.scrb-cd-1.sichuandaily.com.cn
|
|
|
+ Map<String, Object> headers = new HashMap<>();
|
|
|
+ headers.put(HttpHeaders.CONTENT_TYPE, "application/octet-stream");
|
|
|
+ String filePath = "C:\\Users\\dsx\\Downloads\\screencap";
|
|
|
+ ObsClient obsClient = new ObsClient("AFMVGM5CPSHHQ7UPG3DO", "IUYocj8qgixoDxhj3JIVKXtyBV3lGDJBDFgRhO21", "obsv3.scrb-cd-1.sichuandaily.com.cn");
|
|
|
+
|
|
|
+ File file = new File(filePath);
|
|
|
+ ObjectMetadata metadata = new ObjectMetadata();
|
|
|
+ if (CollUtil.isNotEmpty(headers)) {
|
|
|
+ metadata.setContentType("application/octet-stream");
|
|
|
+// metadata.setContentEncoding(headers.get("Content-Encoding"));
|
|
|
+ metadata.setOriginalHeaders(headers);
|
|
|
+ }else{
|
|
|
+ if (filePath.contains(".jpg")) {
|
|
|
+ metadata.setContentType("image/jpeg");
|
|
|
+ }
|
|
|
+ if (filePath.contains(".mp4")) {
|
|
|
+ metadata.setContentType("video/mp4");
|
|
|
+ }
|
|
|
+ if (filePath.contains(".mp3")) {
|
|
|
+ metadata.setContentType("audio/mp3");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PutObjectRequest putObjectRequest = new PutObjectRequest("djqk-vr", "downloads/scene/KJ-t-fTL2wiEjeMS/tour/screencap.mp4", file);
|
|
|
+ putObjectRequest.setMetadata(metadata);
|
|
|
+ putObjectRequest.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
|
|
|
+ obsClient.putObject("djqk-vr", "downloads/scene/KJ-t-fTL2wiEjeMS/tour/screencap.mp4", file, metadata);
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
}
|