|
|
@@ -1,11 +1,15 @@
|
|
|
package cn.reghao.oss.store.service;
|
|
|
|
|
|
import cn.reghao.jutil.jdk.machine.id.MachineId;
|
|
|
+import cn.reghao.oss.api.constant.ObjectScope;
|
|
|
import cn.reghao.oss.api.dto.ObjectChannel;
|
|
|
import cn.reghao.oss.sdk.OssConsoleClient;
|
|
|
import cn.reghao.oss.store.util.UserContext;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @author reghao
|
|
|
* @date 2024-02-28 11:05:34
|
|
|
@@ -31,4 +35,19 @@ public class ObjectChannelService {
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ public List<String> getPublicChannels() {
|
|
|
+ String nodeAddr = machineId.ipv4();
|
|
|
+ try {
|
|
|
+ List<ObjectChannel> list = ossConsoleClient.getObjectChannels(nodeAddr);
|
|
|
+ return list.stream()
|
|
|
+ .filter(objectChannel -> Objects.equals(objectChannel.getScope(), ObjectScope.PUBLIC.getCode()))
|
|
|
+ .map(ObjectChannel::getPrefix)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
}
|