minio 阿里云创建文件夹
时间: 2023-09-05 10:12:12 浏览: 430
minio文件储存服务
您可以使用MinIO的Java SDK来创建文件夹。以下是一个示例代码:
```java
import io.minio.MinioClient;
import io.minio.errors.MinioException;
import io.minio.messages.Bucket;
import io.minio.messages.Item;
public class MinioExample {
public static void main(String[] args) {
try {
// 创建MinIO客户端
MinioClient minioClient = new MinioClient("https://play.min.io",
"accessKey",
"secretKey");
// 创建存储桶
String bucketName = "mybucket";
boolean bucketExists = minioClient.bucketExists(bucketName);
if (!bucketExists) {
minioClient.makeBucket(bucketName);
System.out.println("Bucket created successfully.");
} else {
System.out.println("Bucket already exists.");
}
// 创建文件夹
String folderName = "myfolder";
String objectName = folderName + "/";
minioClient.putObject(bucketName, objectName, null, 0, null);
System.out.println("Folder created successfully.");
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
} catch (Exception e) {
System.out.println("Error occurred: " + e);
}
}
}
```
请确保您已经在阿里云上创建了MinIO实例,并将示例代码中的URL、accessKey和secretKey替换为您自己的信息。运行此代码将在指定的存储桶中创建一个名为"myfolder"的文件夹。
阅读全文