From 75e6eea8cd3fac9cc888e2ffc9cdb126fab8429d Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 14 Aug 2024 15:45:55 +0800
Subject: [PATCH] 任务下发、更新、取消,优化图斑逻辑
---
src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java b/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java
index 9ac8059..d913471 100644
--- a/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java
+++ b/src/main/java/com/dji/sample/component/oss/service/impl/OssServiceContext.java
@@ -1,12 +1,15 @@
package com.dji.sample.component.oss.service.impl;
+import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.component.oss.model.OssConfiguration;
import com.dji.sample.component.oss.model.enums.OssTypeEnum;
import com.dji.sample.component.oss.service.IOssService;
import com.dji.sample.media.model.CredentialsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
@@ -21,16 +24,13 @@
private IOssService ossService;
- private OssConfiguration configuration;
-
@Autowired
public OssServiceContext(List<IOssService> ossServices, OssConfiguration configuration) {
- this.configuration = configuration;
- if (!configuration.isEnable()) {
+ if (!OssConfiguration.enable) {
return;
}
this.ossService = ossServices.stream()
- .filter(ossService -> ossService.getOssType().equals(configuration.getProvider()))
+ .filter(ossService -> ossService.getOssType().equals(OssConfiguration.provider))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Oss provider is illegal. Optional: " +
Arrays.toString(Arrays.stream(OssTypeEnum.values()).map(OssTypeEnum::getType).toArray())));
@@ -45,6 +45,9 @@
}
public URL getObjectUrl(String bucket, String objectKey) {
+ if (!StringUtils.hasText(bucket) || !StringUtils.hasText(objectKey)) {
+ throw new IllegalArgumentException();
+ }
return this.ossService.getObjectUrl(bucket, objectKey);
}
@@ -52,7 +55,15 @@
return this.ossService.deleteObject(bucket, objectKey);
}
- public byte[] getObject(String bucket, String objectKey) {
+ public InputStream getObject(String bucket, String objectKey) {
return this.ossService.getObject(bucket, objectKey);
}
+
+ public String putObject(String bucket, String objectKey, InputStream stream) {
+ return this.ossService.putObject(bucket, objectKey, stream);
+ }
+
+ void createClient() {
+ this.ossService.createClient();
+ }
}
--
Gitblit v1.9.3