刘光辉
118 分钟以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package jnpf.fileStorage;
 
import io.minio.BucketExistsArgs;
import org.dromara.x.file.storage.core.platform.MinioFileStorage;
import org.springframework.stereotype.Component;
 
@Component
public class SeaweedFsBucketVerifier {
 
    public void verify(MinioFileStorage storage) {
        String bucketName = storage.getBucketName();
        try {
            boolean exists = storage.getClient().bucketExists(BucketExistsArgs.builder()
                    .bucket(bucketName)
                    .build());
            if (!exists) {
                throw new IllegalStateException("SeaweedFS bucket 不存在: " + bucketName);
            }
        } catch (IllegalStateException exception) {
            throw exception;
        } catch (Exception exception) {
            throw new IllegalStateException("SeaweedFS bucket 无法访问: " + bucketName, exception);
        }
    }
}