35.7.3. Minio Producer 操作示例
- CopyObject:此操作将对象从一个存储桶复制到不同的存储桶
from("direct:start").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(MinioConstants.DESTINATION_BUCKET_NAME, "camelDestinationBucket");
exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "camelKey");
exchange.getIn().setHeader(MinioConstants.DESTINATION_OBJECT_NAME, "camelDestinationKey");
}
})
.to("minio://mycamelbucket?minioClient=#minioClient&operation=copyObject")
.to("mock:result");
此操作会将带有标头 camelDestinationKey 中 name 表示的对象复制到来自 bucket mycamelbucket 的 camelDestinationBucket bucket。
- DeleteObject:此操作从存储桶中删除对象
from("direct:start").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "camelKey");
}
})
.to("minio://mycamelbucket?minioClient=#minioClient&operation=deleteObject")
.to("mock:result");
此操作将从存储桶 mycamelbucket 中删除对象 camelKey。
- ListBuckets:此操作列出此地区中此帐户的存储桶
from("direct:start")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=listBuckets")
.to("mock:result");
此操作将列出此帐户的存储桶
- DeleteBucket:此操作删除指定为 URI 参数或标头的存储桶
from("direct:start")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=deleteBucket")
.to("mock:result");
此操作将删除存储桶 mycamelbucket
- ListObjects:此操作列表特定存储桶中的对象
from("direct:start")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=listObjects")
.to("mock:result");
此操作将列出 mycamelbucket 存储桶中的对象
- GetObject:此操作获取特定存储桶中的一个对象
from("direct:start").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "camelKey");
}
})
.to("minio://mycamelbucket?minioClient=#minioClient&operation=getObject")
.to("mock:result");
此操作将返回与 mycamelbucket bucket 中 camelKey 对象相关的 MinioObject 实例。
- GetObjectRange:此操作在特定存储桶中获取单个对象范围
from("direct:start").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "camelKey");
exchange.getIn().setHeader(MinioConstants.OFFSET, "0");
exchange.getIn().setHeader(MinioConstants.LENGTH, "9");
}
})
.to("minio://mycamelbucket?minioClient=#minioClient&operation=getObjectRange")
.to("mock:result");
此操作将返回与 mycamelbucket bucket 中 camelKey 对象相关的 MinioObject 实例,其中包含从 0 到 9 的字节数。