本文整理汇总了Java中io.minio.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于io.minio包,在下文中一共展示了Result类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import io.minio.Result; //导入依赖的package包/类
/**
* MinioClient.removeObject() example removing multiple objects.
*/
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<String> objectNames = new LinkedList<String>();
objectNames.add("my-objectname1");
objectNames.add("my-objectname2");
objectNames.add("my-objectname3");
// Remove object all objects 'objectNames' list from 'my-bucketname'.
for (Result<DeleteError> errorResult: minioClient.removeObject("my-bucketname", objectNames)) {
DeleteError error = errorResult.get();
System.out.println("Failed to remove '" + error.objectName() + "'. Error:" + error.message());
}
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
}
示例2: listAlbums
import io.minio.Result; //导入依赖的package包/类
public List<Album> listAlbums() throws NoSuchAlgorithmException,
IOException, InvalidKeyException, XmlPullParserException, MinioException {
List<Album> list = new ArrayList<Album>();
final String minioBucket = "albums";
// Initialize minio client object.
MinioClient minioClient = new MinioClient("play.minio.io", 9000,
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
// List all objects.
Iterable<Result<Item>> myObjects = minioClient.listObjects(minioBucket);
// Iterate over each elements and set album url.
for (Result<Item> result : myObjects) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
// Generate a presigned URL which expires in a day
url = minioClient.presignedGetObject(minioBucket, item.objectName(), 60 * 60 * 24);
// Create a new Album Object
Album album = new Album();
// Set the presigned URL in the album object
album.setUrl(url);
// Add the album object to the list holding Album objects
list.add(album);
}
// Return list of albums.
return list;
}
示例3: main
import io.minio.Result; //导入依赖的package包/类
/**
* MinioClient.listIncompleteUploads() 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");
// Check whether 'my-bucketname' exist or not.
boolean found = minioClient.bucketExists("my-bucketname");
if (found) {
// List all incomplete multipart upload of objects in 'my-bucketname'
Iterable<Result<Upload>> myObjects = minioClient.listIncompleteUploads("my-bucketname");
for (Result<Upload> result : myObjects) {
Upload upload = result.get();
System.out.println(upload.uploadId() + ", " + upload.objectName());
}
} else {
System.out.println("my-bucketname does not exist");
}
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
}
示例4: main
import io.minio.Result; //导入依赖的package包/类
/**
* MinioClient.listObjects() 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");
// Check whether 'my-bucketname' exist or not.
boolean found = minioClient.bucketExists("my-bucketname");
if (found) {
// List objects from 'my-bucketname'
Iterable<Result<Item>> myObjects = minioClient.listObjects("my-bucketname");
for (Result<Item> result : myObjects) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}
} else {
System.out.println("my-bucketname does not exist");
}
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
}