本文整理汇总了Java中io.minio.messages.Bucket类的典型用法代码示例。如果您正苦于以下问题:Java Bucket类的具体用法?Java Bucket怎么用?Java Bucket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bucket类属于io.minio.messages包,在下文中一共展示了Bucket类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import io.minio.messages.Bucket; //导入依赖的package包/类
/**
* MinioClient.listBuckets() example.
*/
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException, XmlPullParserException {
try {
/* play.minio.io for test and development. */
MinioClient minioClient = new MinioClient("https://play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// List buckets we have atleast read access.
List<Bucket> bucketList = minioClient.listBuckets();
for (Bucket bucket : bucketList) {
System.out.println(bucket.creationDate() + ", " + bucket.name());
}
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
}
示例2: listBuckets
import io.minio.messages.Bucket; //导入依赖的package包/类
@Override
public List<S3BucketInfo> listBuckets() {
try {
S3ConnectionProperties connectionProperties =
connectionPropertiesProvider.getConnectionProperties();
MinioClient minioClient = this.clientBuilder.buildMinioClient(connectionProperties);
List<Bucket> bucketList = minioClient.listBuckets();
return bucketList.stream()
.map(bucket -> new S3BucketInfo(bucket.name(), bucket.creationDate()))
.collect(Collectors.toList());
} catch (Exception ex) {
log.error("Failed to get list of buckets; " + ex.getMessage(), ex);
throw new RuntimeException("Failed to get list of buckets");
} // try{}
}
示例3: testListBuckets
import io.minio.messages.Bucket; //导入依赖的package包/类
@Test
public void testListBuckets()
throws NoSuchAlgorithmException, InvalidKeyException, IOException, XmlPullParserException, MinioException,
ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
final String body = "<ListAllMyBucketsResult xmlns=\"http://doc.s3.amazonaws.com/2006-03-01\"><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-05-05T20:35:51.410Z</CreationDate></Bucket><Bucket><Name>foo</Name><CreationDate>2015-05-05T20:35:47.170Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>";
MockWebServer server = new MockWebServer();
MockResponse response = new MockResponse();
response.addHeader("Date", SUN_29_JUN_2015_22_01_10_GMT);
response.addHeader(CONTENT_LENGTH, "351");
response.addHeader(CONTENT_TYPE, "application/xml");
response.setBody(new Buffer().writeUtf8(body));
response.setResponseCode(200);
server.enqueue(response);
server.start();
MinioClient client = new MinioClient(server.url(""));
Iterator<Bucket> buckets = client.listBuckets().iterator();
Bucket bucket = buckets.next();
assertEquals(BUCKET, bucket.name());
assertEquals(dateFormat.parse("2015-05-05T20:35:51.410Z"), bucket.creationDate());
bucket = buckets.next();
assertEquals("foo", bucket.name());
assertEquals(dateFormat.parse("2015-05-05T20:35:47.170Z"), bucket.creationDate());
Calendar expectedDate = Calendar.getInstance();
expectedDate.clear();
expectedDate.setTimeZone(TimeZone.getTimeZone("UTC"));
expectedDate.set(2015, Calendar.MAY, 5, 20, 35, 47);
expectedDate.set(Calendar.MILLISECOND, 170);
assertEquals(expectedDate.getTime(), bucket.creationDate());
}
示例4: listBuckets
import io.minio.messages.Bucket; //导入依赖的package包/类
/**
* Returns all bucket information owned by the current user.
*
* </p><b>Example:</b><br>
* <pre>{@code List<Bucket> bucketList = minioClient.listBuckets();
* for (Bucket bucket : bucketList) {
* System.out.println(bucket.creationDate() + ", " + bucket.name());
* } }</pre>
*
* @return List of bucket type.
*
* @throws NoResponseException upon no response from server
* @throws IOException upon connection error
* @throws XmlPullParserException upon parsing response xml
* @throws ErrorResponseException upon unsuccessful execution
* @throws InternalException upon internal library error
*/
public List<Bucket> listBuckets()
throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException,
InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
InternalException {
HttpResponse response = executeGet(null, null, null, null);
ListAllMyBucketsResult result = new ListAllMyBucketsResult();
result.parseXml(response.body().charStream());
response.body().close();
return result.buckets();
}