|
@@ -1,21 +1,14 @@
|
|
package com.fdkankan.scene.util;
|
|
package com.fdkankan.scene.util;
|
|
|
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
|
-import cn.hutool.http.HttpUtil;
|
|
|
|
import com.aliyun.imageseg20191230.models.SegmentBodyResponse;
|
|
import com.aliyun.imageseg20191230.models.SegmentBodyResponse;
|
|
-import com.aliyun.oss.OSS;
|
|
|
|
-import com.aliyun.oss.OSSClientBuilder;
|
|
|
|
-import com.aliyun.tea.TeaException;
|
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.scene.httpclient.MyClient;
|
|
import com.fdkankan.scene.httpclient.MyClient;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.io.File;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Component
|
|
@Component
|
|
@@ -41,19 +34,19 @@ public class OssBodySegmentUtil {
|
|
private MyClient myClient;
|
|
private MyClient myClient;
|
|
|
|
|
|
public void uploadOss(String filePath, String key){
|
|
public void uploadOss(String filePath, String key){
|
|
- OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
|
|
|
|
- try {
|
|
|
|
- File file = new File(filePath);
|
|
|
|
- if (!file.exists()) {
|
|
|
|
- log.error("要上传的文件不存在:" + filePath);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- ossClient.putObject(bucket, key, new File(filePath));
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error(e.toString() + filePath);
|
|
|
|
- } finally {
|
|
|
|
- ossClient.shutdown();
|
|
|
|
- }
|
|
|
|
|
|
+// OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
|
|
|
|
+// try {
|
|
|
|
+// File file = new File(filePath);
|
|
|
|
+// if (!file.exists()) {
|
|
|
|
+// log.error("要上传的文件不存在:" + filePath);
|
|
|
|
+// return;
|
|
|
|
+// }
|
|
|
|
+// ossClient.putObject(bucket, key, new File(filePath));
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// log.error(e.toString() + filePath);
|
|
|
|
+// } finally {
|
|
|
|
+// ossClient.shutdown();
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
public void extracted(String imageUrl, String dir, String fileName) throws Exception {
|
|
public void extracted(String imageUrl, String dir, String fileName) throws Exception {
|