Package io.minio
Class MinioClient
java.lang.Object
io.minio.S3Base
io.minio.MinioClient
Simple Storage Service (aka S3) client to perform bucket and object operations.
Bucket operations
- Create, list and delete buckets.
- Put, get and delete bucket lifecycle configuration.
- Put, get and delete bucket policy configuration.
- Put, get and delete bucket encryption configuration.
- Put and get bucket default retention configuration.
- Put and get bucket notification configuration.
- Enable and disable bucket versioning.
Object operations
- Put, get, delete and list objects.
- Create objects by combining existing objects.
- Put and get object retention and legal hold.
- Filter object content by SQL statement.
If access/secret keys are provided, all S3 operation requests are signed using AWS Signature Version 4; else they are performed anonymously.
Examples on using this library are available here.
Use MinioClient.builder() to create S3 client.
// Create client with anonymous access.
MinioClient minioClient = MinioClient.builder().endpoint("https://play.min.io").build();
// Create client with credentials.
MinioClient minioClient =
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class io.minio.S3Base
S3Base.NotificationResultRecords -
Field Summary
Fields inherited from class io.minio.S3Base
baseUrl, DEFAULT_CONNECTION_TIMEOUT, MAX_BUCKET_POLICY_SIZE, NO_SUCH_BUCKET, NO_SUCH_BUCKET_MESSAGE, NO_SUCH_BUCKET_POLICY, NO_SUCH_OBJECT_LOCK_CONFIGURATION, provider, region, regionCache, SERVER_SIDE_ENCRYPTION_CONFIGURATION_NOT_FOUND_ERROR, US_EAST_1 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbucketExists(BucketExistsArgs args) Checks if a bucket exists.static MinioClient.Builderbuilder()Creates an object by combining data from different source objects using server-side copy.copyObject(CopyObjectArgs args) Creates an object by server-side copying data from another object.voidDeletes encryption configuration of a bucket.voidDeletes lifecycle configuration of a bucket.voidDeletes notification configuration of a bucket.voidDeletes bucket policy configuration to a bucket.voidDeletes bucket replication configuration from a bucket.voidDeletes tags of a bucket.voidDeletes default object retention in a bucket.voidDeletes tags of an object.voidDisables legal hold on an object.voidDownloads data of a SSE-C encrypted object to file.voidEnables legal hold on an object.Gets encryption configuration of a bucket.Gets lifecycle configuration of a bucket.Gets notification configuration of a bucket.Gets bucket policy configuration of a bucket.Gets bucket replication configuration of a bucket.Gets tags of a bucket.Gets versioning configuration of a bucket.getObject(GetObjectArgs args) Gets data from offset to length of a SSE-C encrypted object.Gets default object retention in a bucket.Gets retention configuration of an object.Gets tags of an object.Gets presigned URL of an object for HTTP method, expiry time and custom request parameters.getPresignedPostFormData(PostPolicy policy) Gets form-data ofPostPolicyof an object to upload its data using POST method.booleanReturns true if legal hold is enabled on an object.Lists bucket information of all buckets.listBuckets(ListBucketsArgs args) Lists bucket information of all buckets.Listens events of object prefix and suffix of a bucket.listObjects(ListObjectsArgs args) Lists objects information optionally with versions of a bucket.voidmakeBucket(MakeBucketArgs args) Creates a bucket with region and object lock.putObject(PutObjectArgs args) Uploads data from a stream to an object.voidremoveBucket(RemoveBucketArgs args) Removes an empty bucket using argumentsvoidremoveObject(RemoveObjectArgs args) Removes an object.Removes multiple objects lazily.Selects content of an object by SQL expression.voidSets encryption configuration of a bucket.voidSets lifecycle configuration to a bucket.voidSets notification configuration to a bucket.voidSets bucket policy configuration to a bucket.voidSets bucket replication configuration to a bucket.voidSets tags to a bucket.voidSets versioning configuration of a bucket.voidSets default object retention in a bucket.voidSets retention configuration to an object.voidSets tags to an object.statObject(StatObjectArgs args) Gets information of an object.uploadObject(UploadObjectArgs args) Uploads data from a file to an object.Uploads multiple objects in a single put call.Methods inherited from class io.minio.S3Base
abortMultipartUpload, buildUrl, calculatePartCount, checkArgs, completeMultipartUpload, createMultipartUpload, createRequest, deleteObjects, disableAccelerateEndpoint, disableDualStackEndpoint, disableVirtualStyleEndpoint, enableAccelerateEndpoint, enableDualStackEndpoint, enableVirtualStyleEndpoint, execute, execute, executeDelete, executeGet, executeHead, executePost, executePut, getRegion, httpHeaders, ignoreCertCheck, listMultipartUploads, listObjectsV1, listObjectsV1, listObjectsV2, listObjectsV2, listObjectVersions, listObjectVersions, listParts, merge, newMultimap, newMultimap, newMultimap, putObject, putObject, setAppInfo, setTimeout, traceOff, traceOn, uploadPart, uploadPartCopy
-
Constructor Details
-
MinioClient
-
-
Method Details
-
statObject
public StatObjectResponse statObject(StatObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets information of an object.Example:
// Get information of an object. StatObjectResponse stat = minioClient.statObject( StatObjectArgs.builder().bucket("my-bucketname").object("my-objectname").build()); // Get information of SSE-C encrypted object. StatObjectResponse stat = minioClient.statObject( StatObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .ssec(ssec) .build()); // Get information of a versioned object. StatObjectResponse stat = minioClient.statObject( StatObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .versionId("version-id") .build()); // Get information of a SSE-C encrypted versioned object. StatObjectResponse stat = minioClient.statObject( StatObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .versionId("version-id") .ssec(ssec) .build());- Overrides:
statObjectin classS3Base- Parameters:
args-StatObjectArgsobject.- Returns:
StatObjectResponse- Populated object information and metadata.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException- See Also:
-
getObject
public GetObjectResponse getObject(GetObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets data from offset to length of a SSE-C encrypted object. ReturnedInputStreammust be closed after use to release network resources.Example:
try (InputStream stream = minioClient.getObject( GetObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .offset(offset) .length(len) .ssec(ssec) .build() ) { // Read data from stream }- Parameters:
args- Object ofGetObjectArgs- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
downloadObject
public void downloadObject(DownloadObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Downloads data of a SSE-C encrypted object to file.Example:
minioClient.downloadObject( DownloadObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .ssec(ssec) .filename("my-filename") .build());- Parameters:
args- Object ofDownloadObjectArgs- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
copyObject
public ObjectWriteResponse copyObject(CopyObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Creates an object by server-side copying data from another object.Example:
// Create object "my-objectname" in bucket "my-bucketname" by copying from object // "my-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-objectname") .build()) .build()); // Create object "my-objectname" in bucket "my-bucketname" by copying from object // "my-source-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-source-objectname") .build()) .build()); // Create object "my-objectname" in bucket "my-bucketname" with SSE-KMS server-side // encryption by copying from object "my-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-objectname") .build()) .sse(sseKms) // Replace with actual key. .build()); // Create object "my-objectname" in bucket "my-bucketname" with SSE-S3 server-side // encryption by copying from object "my-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-objectname") .build()) .sse(sseS3) // Replace with actual key. .build()); // Create object "my-objectname" in bucket "my-bucketname" with SSE-C server-side encryption // by copying from object "my-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-objectname") .build()) .sse(ssec) // Replace with actual key. .build()); // Create object "my-objectname" in bucket "my-bucketname" by copying from SSE-C encrypted // object "my-source-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-source-objectname") .ssec(ssec) // Replace with actual key. .build()) .build()); // Create object "my-objectname" in bucket "my-bucketname" with custom headers conditionally // by copying from object "my-objectname" in bucket "my-source-bucketname". minioClient.copyObject( CopyObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .source( CopySource.builder() .bucket("my-source-bucketname") .object("my-objectname") .matchETag(etag) // Replace with actual etag. .build()) .headers(headers) // Replace with actual headers. .build());- Parameters:
args-CopyObjectArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
composeObject
public ObjectWriteResponse composeObject(ComposeObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Creates an object by combining data from different source objects using server-side copy.Example:
List<ComposeSource> sourceObjectList = new ArrayList<ComposeSource>(); sourceObjectList.add( ComposeSource.builder().bucket("my-job-bucket").object("my-objectname-part-one").build()); sourceObjectList.add( ComposeSource.builder().bucket("my-job-bucket").object("my-objectname-part-two").build()); sourceObjectList.add( ComposeSource.builder().bucket("my-job-bucket").object("my-objectname-part-three").build()); // Create my-bucketname/my-objectname by combining source object list. minioClient.composeObject( ComposeObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .sources(sourceObjectList) .build()); // Create my-bucketname/my-objectname with user metadata by combining source object // list. Map<String, String> userMetadata = new HashMap<>(); userMetadata.put("My-Project", "Project One"); minioClient.composeObject( ComposeObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .sources(sourceObjectList) .userMetadata(userMetadata) .build()); // Create my-bucketname/my-objectname with user metadata and server-side encryption // by combining source object list. minioClient.composeObject( ComposeObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .sources(sourceObjectList) .userMetadata(userMetadata) .ssec(sse) .build());- Parameters:
args-ComposeObjectArgsobject.- Returns:
ObjectWriteResponseobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getPresignedObjectUrl
public String getPresignedObjectUrl(GetPresignedObjectUrlArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException, ServerException Gets presigned URL of an object for HTTP method, expiry time and custom request parameters.Example:
// Get presigned URL string to delete 'my-objectname' in 'my-bucketname' and its life time // is one day. String url = minioClient.getPresignedObjectUrl( GetPresignedObjectUrlArgs.builder() .method(Method.DELETE) .bucket("my-bucketname") .object("my-objectname") .expiry(24 * 60 * 60) .build()); System.out.println(url); // Get presigned URL string to upload 'my-objectname' in 'my-bucketname' // with response-content-type as application/json and life time as one day. Map<String, String> reqParams = new HashMap<String, String>(); reqParams.put("response-content-type", "application/json"); String url = minioClient.getPresignedObjectUrl( GetPresignedObjectUrlArgs.builder() .method(Method.PUT) .bucket("my-bucketname") .object("my-objectname") .expiry(1, TimeUnit.DAYS) .extraQueryParams(reqParams) .build()); System.out.println(url); // Get presigned URL string to download 'my-objectname' in 'my-bucketname' and its life time // is 2 hours. String url = minioClient.getPresignedObjectUrl( GetPresignedObjectUrlArgs.builder() .method(Method.GET) .bucket("my-bucketname") .object("my-objectname") .expiry(2, TimeUnit.HOURS) .build()); System.out.println(url);- Parameters:
args-GetPresignedObjectUrlArgsobject.- Returns:
- String - URL string.
- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getPresignedPostFormData
public Map<String,String> getPresignedPostFormData(PostPolicy policy) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets form-data ofPostPolicyof an object to upload its data using POST method.Example:
// Create new post policy for 'my-bucketname' with 7 days expiry from now. PostPolicy policy = new PostPolicy("my-bucketname", ZonedDateTime.now().plusDays(7)); // Add condition that 'key' (object name) equals to 'my-objectname'. policy.addEqualsCondition("key", "my-objectname"); // Add condition that 'Content-Type' starts with 'image/'. policy.addStartsWithCondition("Content-Type", "image/"); // Add condition that 'content-length-range' is between 64kiB to 10MiB. policy.addContentLengthRangeCondition(64 * 1024, 10 * 1024 * 1024); Map<String, String> formData = minioClient.getPresignedPostFormData(policy); // Upload an image using POST object with form-data. MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); for (Map.Entry<String, String> entry : formData.entrySet()) { multipartBuilder.addFormDataPart(entry.getKey(), entry.getValue()); } multipartBuilder.addFormDataPart("key", "my-objectname"); multipartBuilder.addFormDataPart("Content-Type", "image/png"); // "file" must be added at last. multipartBuilder.addFormDataPart( "file", "my-objectname", RequestBody.create(new File("Pictures/avatar.png"), null)); Request request = new Request.Builder() .url("https://play.min.io/my-bucketname") .post(multipartBuilder.build()) .build(); OkHttpClient httpClient = new OkHttpClient().newBuilder().build(); Response response = httpClient.newCall(request).execute(); if (response.isSuccessful()) { System.out.println("Pictures/avatar.png is uploaded successfully using POST object"); } else { System.out.println("Failed to upload Pictures/avatar.png"); }- Parameters:
policy- Post policy of an object.- Returns:
Map<String, String>- Contains form-data to upload an object using POST method.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException- See Also:
-
removeObject
public void removeObject(RemoveObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Removes an object.Example:
// Remove object. minioClient.removeObject( RemoveObjectArgs.builder().bucket("my-bucketname").object("my-objectname").build()); // Remove versioned object. minioClient.removeObject( RemoveObjectArgs.builder() .bucket("my-bucketname") .object("my-versioned-objectname") .versionId("my-versionid") .build()); // Remove versioned object bypassing Governance mode. minioClient.removeObject( RemoveObjectArgs.builder() .bucket("my-bucketname") .object("my-versioned-objectname") .versionId("my-versionid") .bypassRetentionMode(true) .build());- Parameters:
args-RemoveObjectArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
removeObjects
Removes multiple objects lazily. Its required to iterate the returned Iterable to perform removal.Example:
List<DeleteObject> objects = new LinkedList<>(); objects.add(new DeleteObject("my-objectname1")); objects.add(new DeleteObject("my-objectname2")); objects.add(new DeleteObject("my-objectname3")); Iterable<Result<DeleteError>> results = minioClient.removeObjects( RemoveObjectsArgs.builder().bucket("my-bucketname").objects(objects).build()); for (Result<DeleteError> result : results) { DeleteError error = errorResult.get(); System.out.println( "Error in deleting object " + error.objectName() + "; " + error.message()); }- Parameters:
args-RemoveObjectsArgsobject.- Returns:
Iterable<Result<DeleteError>>- Lazy iterator contains object removal status.
-
listObjects
Lists objects information optionally with versions of a bucket. Supports both the versions 1 and 2 of the S3 API. By default, the version 2 API is used.
Version 1 can be used by passing the optional argumentuseVersion1astrue.Example:
// Lists objects information. Iterable<Result<Item>> results = minioClient.listObjects( ListObjectsArgs.builder().bucket("my-bucketname").build()); // Lists objects information recursively. Iterable<Result<Item>> results = minioClient.listObjects( ListObjectsArgs.builder().bucket("my-bucketname").recursive(true).build()); // Lists maximum 100 objects information whose names starts with 'E' and after // 'ExampleGuide.pdf'. Iterable<Result<Item>> results = minioClient.listObjects( ListObjectsArgs.builder() .bucket("my-bucketname") .startAfter("ExampleGuide.pdf") .prefix("E") .maxKeys(100) .build()); // Lists maximum 100 objects information with version whose names starts with 'E' and after // 'ExampleGuide.pdf'. Iterable<Result<Item>> results = minioClient.listObjects( ListObjectsArgs.builder() .bucket("my-bucketname") .startAfter("ExampleGuide.pdf") .prefix("E") .maxKeys(100) .includeVersions(true) .build());- Parameters:
args- Instance ofListObjectsArgsbuilt using the builder- Returns:
Iterable<Result<Item>>- Lazy iterator contains object information.- Throws:
XmlParserException- upon parsing response xml
-
listBuckets
public List<Bucket> listBuckets() throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserExceptionLists bucket information of all buckets.Example:
List<Bucket> bucketList = minioClient.listBuckets(); for (Bucket bucket : bucketList) { System.out.println(bucket.creationDate() + ", " + bucket.name()); }- Returns:
List<Bucket>- List of bucket information.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
listBuckets
public List<Bucket> listBuckets(ListBucketsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Lists bucket information of all buckets.Example:
List<Bucket> bucketList = minioClient.listBuckets(ListBucketsArgs.builder().extraHeaders(headers).build()); for (Bucket bucket : bucketList) { System.out.println(bucket.creationDate() + ", " + bucket.name()); }- Returns:
List<Bucket>- List of bucket information.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
bucketExists
public boolean bucketExists(BucketExistsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Checks if a bucket exists.Example:
boolean found = minioClient.bucketExists(BucketExistsArgs.builder().bucket("my-bucketname").build()); if (found) { System.out.println("my-bucketname exists"); } else { System.out.println("my-bucketname does not exist"); }- Parameters:
args-BucketExistsArgsobject.- Returns:
- boolean - True if the bucket exists.
- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
makeBucket
public void makeBucket(MakeBucketArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Creates a bucket with region and object lock.Example:
// Create bucket with default region. minioClient.makeBucket( MakeBucketArgs.builder() .bucket("my-bucketname") .build()); // Create bucket with specific region. minioClient.makeBucket( MakeBucketArgs.builder() .bucket("my-bucketname") .region("us-west-1") .build()); // Create object-lock enabled bucket with specific region. minioClient.makeBucket( MakeBucketArgs.builder() .bucket("my-bucketname") .region("us-west-1") .objectLock(true) .build());- Parameters:
args- Object with bucket name, region and lock functionality- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketVersioning
public void setBucketVersioning(SetBucketVersioningArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets versioning configuration of a bucket.Example:
minioClient.setBucketVersioning( SetBucketVersioningArgs.builder().bucket("my-bucketname").config(config).build());- Parameters:
args-SetBucketVersioningArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketVersioning
public VersioningConfiguration getBucketVersioning(GetBucketVersioningArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets versioning configuration of a bucket.Example:
VersioningConfiguration config = minioClient.getBucketVersioning( GetBucketVersioningArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketVersioningArgsobject.- Returns:
VersioningConfiguration- Versioning configuration.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setObjectLockConfiguration
public void setObjectLockConfiguration(SetObjectLockConfigurationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets default object retention in a bucket.Example:
ObjectLockConfiguration config = new ObjectLockConfiguration( RetentionMode.COMPLIANCE, new RetentionDurationDays(100)); minioClient.setObjectLockConfiguration( SetObjectLockConfigurationArgs.builder().bucket("my-bucketname").config(config).build());- Parameters:
args-SetObjectLockConfigurationArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteObjectLockConfiguration
public void deleteObjectLockConfiguration(DeleteObjectLockConfigurationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes default object retention in a bucket.Example:
minioClient.deleteObjectLockConfiguration( DeleteObjectLockConfigurationArgs.builder().bucket("my-bucketname").build());- Parameters:
args-DeleteObjectLockConfigurationArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getObjectLockConfiguration
public ObjectLockConfiguration getObjectLockConfiguration(GetObjectLockConfigurationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets default object retention in a bucket.Example:
ObjectLockConfiguration config = minioClient.getObjectLockConfiguration( GetObjectLockConfigurationArgs.builder().bucket("my-bucketname").build()); System.out.println("Mode: " + config.mode()); System.out.println( "Duration: " + config.duration().duration() + " " + config.duration().unit());- Parameters:
args-GetObjectLockConfigurationArgsobject.- Returns:
ObjectLockConfiguration- Default retention configuration.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setObjectRetention
public void setObjectRetention(SetObjectRetentionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets retention configuration to an object.Example:
Retention retention = new Retention( RetentionMode.COMPLIANCE, ZonedDateTime.now().plusYears(1)); minioClient.setObjectRetention( SetObjectRetentionArgs.builder() .bucket("my-bucketname") .object("my-objectname") .config(config) .bypassGovernanceMode(true) .build());- Parameters:
args-SetObjectRetentionArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getObjectRetention
public Retention getObjectRetention(GetObjectRetentionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets retention configuration of an object.Example:
Retention retention = minioClient.getObjectRetention(GetObjectRetentionArgs.builder() .bucket(bucketName) .object(objectName) .versionId(versionId) .build());); System.out.println( "mode: " + retention.mode() + "until: " + retention.retainUntilDate());- Parameters:
args-GetObjectRetentionArgsobject.- Returns:
Retention- Object retention configuration.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
enableObjectLegalHold
public void enableObjectLegalHold(EnableObjectLegalHoldArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Enables legal hold on an object.Example:
minioClient.enableObjectLegalHold( EnableObjectLegalHoldArgs.builder() .bucket("my-bucketname") .object("my-objectname") .versionId("object-versionId") .build());- Parameters:
args-EnableObjectLegalHoldArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
disableObjectLegalHold
public void disableObjectLegalHold(DisableObjectLegalHoldArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Disables legal hold on an object.Example:
minioClient.disableObjectLegalHold( DisableObjectLegalHoldArgs.builder() .bucket("my-bucketname") .object("my-objectname") .versionId("object-versionId") .build());- Parameters:
args-DisableObjectLegalHoldArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
isObjectLegalHoldEnabled
public boolean isObjectLegalHoldEnabled(IsObjectLegalHoldEnabledArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Returns true if legal hold is enabled on an object.Example:
argsboolean status = s3Client.isObjectLegalHoldEnabled( IsObjectLegalHoldEnabledArgs.builder() .bucket("my-bucketname") .object("my-objectname") .versionId("object-versionId") .build()); if (status) { System.out.println("Legal hold is on"); } else { System.out.println("Legal hold is off"); }IsObjectLegalHoldEnabledArgsobject.- Returns:
- boolean - True if legal hold is enabled.
- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
removeBucket
public void removeBucket(RemoveBucketArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Removes an empty bucket using argumentsExample:
minioClient.removeBucket(RemoveBucketArgs.builder().bucket("my-bucketname").build());- Parameters:
args-RemoveBucketArgsbucket.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
putObject
public ObjectWriteResponse putObject(PutObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Uploads data from a stream to an object.Example:
// Upload known sized input stream. minioClient.putObject( PutObjectArgs.builder().bucket("my-bucketname").object("my-objectname").stream( inputStream, size, -1) .contentType("video/mp4") .build()); // Upload unknown sized input stream. minioClient.putObject( PutObjectArgs.builder().bucket("my-bucketname").object("my-objectname").stream( inputStream, -1, 10485760) .contentType("video/mp4") .build()); // Create object ends with '/' (also called as folder or directory). minioClient.putObject( PutObjectArgs.builder().bucket("my-bucketname").object("path/to/").stream( new ByteArrayInputStream(new byte[] {}), 0, -1) .build()); // Upload input stream with headers and user metadata. Map<String, String> headers = new HashMap<>(); headers.put("X-Amz-Storage-Class", "REDUCED_REDUNDANCY"); Map<String, String> userMetadata = new HashMap<>(); userMetadata.put("My-Project", "Project One"); minioClient.putObject( PutObjectArgs.builder().bucket("my-bucketname").object("my-objectname").stream( inputStream, size, -1) .headers(headers) .userMetadata(userMetadata) .build()); // Upload input stream with server-side encryption. minioClient.putObject( PutObjectArgs.builder().bucket("my-bucketname").object("my-objectname").stream( inputStream, size, -1) .sse(sse) .build());- Parameters:
args-PutObjectArgsobject.- Returns:
ObjectWriteResponseobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
uploadObject
public ObjectWriteResponse uploadObject(UploadObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Uploads data from a file to an object.Example:
// Upload an JSON file. minioClient.uploadObject( UploadObjectArgs.builder() .bucket("my-bucketname").object("my-objectname").filename("person.json").build()); // Upload a video file. minioClient.uploadObject( UploadObjectArgs.builder() .bucket("my-bucketname") .object("my-objectname") .filename("my-video.avi") .contentType("video/mp4") .build());- Parameters:
args-UploadObjectArgsobject.- Returns:
ObjectWriteResponseobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketPolicy
public String getBucketPolicy(GetBucketPolicyArgs args) throws BucketPolicyTooLargeException, ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets bucket policy configuration of a bucket.Example:
String config = minioClient.getBucketPolicy(GetBucketPolicyArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketPolicyArgsobject.- Returns:
- String - Bucket policy configuration as JSON string.
- Throws:
BucketPolicyTooLargeException- thrown to indicate returned bucket policy is too large.ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketPolicy
public void setBucketPolicy(SetBucketPolicyArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets bucket policy configuration to a bucket.Example:
// Assume policyJson contains below JSON string; // { // "Statement": [ // { // "Action": [ // "s3:GetBucketLocation", // "s3:ListBucket" // ], // "Effect": "Allow", // "Principal": "*", // "Resource": "arn:aws:s3:::my-bucketname" // }, // { // "Action": "s3:GetObject", // "Effect": "Allow", // "Principal": "*", // "Resource": "arn:aws:s3:::my-bucketname/myobject*" // } // ], // "Version": "2012-10-17" // } // minioClient.setBucketPolicy( SetBucketPolicyArgs.builder().bucket("my-bucketname").config(policyJson).build());- Parameters:
args-SetBucketPolicyArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteBucketPolicy
public void deleteBucketPolicy(DeleteBucketPolicyArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes bucket policy configuration to a bucket.Example:
minioClient.deleteBucketPolicy(DeleteBucketPolicyArgs.builder().bucket("my-bucketname"));- Parameters:
args-DeleteBucketPolicyArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketLifecycle
public void setBucketLifecycle(SetBucketLifecycleArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets lifecycle configuration to a bucket.Example:
List<LifecycleRule> rules = new LinkedList<>(); rules.add( new LifecycleRule( Status.ENABLED, null, new Expiration((ZonedDateTime) null, 365, null), new RuleFilter("logs/"), "rule2", null, null, null)); LifecycleConfiguration config = new LifecycleConfiguration(rules); minioClient.setBucketLifecycle( SetBucketLifecycleArgs.builder().bucket("my-bucketname").config(config).build());- Parameters:
args-SetBucketLifecycleArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteBucketLifecycle
public void deleteBucketLifecycle(DeleteBucketLifecycleArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes lifecycle configuration of a bucket.Example:
deleteBucketLifecycle(DeleteBucketLifecycleArgs.builder().bucket("my-bucketname").build());- Parameters:
args-DeleteBucketLifecycleArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketLifecycle
public LifecycleConfiguration getBucketLifecycle(GetBucketLifecycleArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets lifecycle configuration of a bucket.Example:
LifecycleConfiguration config = minioClient.getBucketLifecycle( GetBucketLifecycleArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketLifecycleArgsobject.- Returns:
LifecycleConfigurationobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketNotification
public NotificationConfiguration getBucketNotification(GetBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets notification configuration of a bucket.Example:
NotificationConfiguration config = minioClient.getBucketNotification( GetBucketNotificationArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketNotificationArgsobject.- Returns:
NotificationConfiguration- Notification configuration.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketNotification
public void setBucketNotification(SetBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets notification configuration to a bucket.Example:
List<EventType> eventList = new LinkedList<>(); eventList.add(EventType.OBJECT_CREATED_PUT); eventList.add(EventType.OBJECT_CREATED_COPY); QueueConfiguration queueConfiguration = new QueueConfiguration(); queueConfiguration.setQueue("arn:minio:sqs::1:webhook"); queueConfiguration.setEvents(eventList); queueConfiguration.setPrefixRule("images"); queueConfiguration.setSuffixRule("pg"); List<QueueConfiguration> queueConfigurationList = new LinkedList<>(); queueConfigurationList.add(queueConfiguration); NotificationConfiguration config = new NotificationConfiguration(); config.setQueueConfigurationList(queueConfigurationList); minioClient.setBucketNotification( SetBucketNotificationArgs.builder().bucket("my-bucketname").config(config).build());- Parameters:
args-SetBucketNotificationArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteBucketNotification
public void deleteBucketNotification(DeleteBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes notification configuration of a bucket.Example:
minioClient.deleteBucketNotification( DeleteBucketNotificationArgs.builder().bucket("my-bucketname").build());- Parameters:
args-DeleteBucketNotificationArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketReplication
public ReplicationConfiguration getBucketReplication(GetBucketReplicationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets bucket replication configuration of a bucket.Example:
ReplicationConfiguration config = minioClient.getBucketReplication( GetBucketReplicationArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketReplicationArgsobject.- Returns:
ReplicationConfigurationobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketReplication
public void setBucketReplication(SetBucketReplicationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets bucket replication configuration to a bucket.Example:
Map<String, String> tags = new HashMap<>(); tags.put("key1", "value1"); tags.put("key2", "value2"); ReplicationRule rule = new ReplicationRule( new DeleteMarkerReplication(Status.DISABLED), new ReplicationDestination( null, null, "REPLACE-WITH-ACTUAL-DESTINATION-BUCKET-ARN", null, null, null, null), null, new RuleFilter(new AndOperator("TaxDocs", tags)), "rule1", null, 1, null, Status.ENABLED); List<ReplicationRule> rules = new LinkedList<>(); rules.add(rule); ReplicationConfiguration config = new ReplicationConfiguration("REPLACE-WITH-ACTUAL-ROLE", rules); minioClient.setBucketReplication( SetBucketReplicationArgs.builder().bucket("my-bucketname").config(config).build());- Parameters:
args-SetBucketReplicationArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteBucketReplication
public void deleteBucketReplication(DeleteBucketReplicationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes bucket replication configuration from a bucket.Example:
minioClient.deleteBucketReplication( DeleteBucketReplicationArgs.builder().bucket("my-bucketname"));- Parameters:
args-DeleteBucketReplicationArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
listenBucketNotification
public CloseableIterator<Result<NotificationRecords>> listenBucketNotification(ListenBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Listens events of object prefix and suffix of a bucket. The returned closable iterator is lazily evaluated hence its required to iterate to get new records and must be used with try-with-resource to release underneath network resources.Example:
String[] events = {"s3:ObjectCreated:*", "s3:ObjectAccessed:*"}; try (CloseableIterator<Result<NotificationRecords>> ci = minioClient.listenBucketNotification( ListenBucketNotificationArgs.builder() .bucket("bucketName") .prefix("") .suffix("") .events(events) .build())) { while (ci.hasNext()) { NotificationRecords records = ci.next().get(); for (Event event : records.events()) { System.out.println("Event " + event.eventType() + " occurred at " + event.eventTime() + " for " + event.bucketName() + "/" + event.objectName()); } } }- Parameters:
args-ListenBucketNotificationArgsobject.- Returns:
CloseableIterator<Result<NotificationRecords>>- Lazy closable iterator contains event records.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
selectObjectContent
public SelectResponseStream selectObjectContent(SelectObjectContentArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Selects content of an object by SQL expression.Example:
String sqlExpression = "select * from S3Object"; InputSerialization is = new InputSerialization(null, false, null, null, FileHeaderInfo.USE, null, null, null); OutputSerialization os = new OutputSerialization(null, null, null, QuoteFields.ASNEEDED, null); SelectResponseStream stream = minioClient.selectObjectContent( SelectObjectContentArgs.builder() .bucket("my-bucketname") .object("my-objectname") .sqlExpression(sqlExpression) .inputSerialization(is) .outputSerialization(os) .requestProgress(true) .build()); byte[] buf = new byte[512]; int bytesRead = stream.read(buf, 0, buf.length); System.out.println(new String(buf, 0, bytesRead, StandardCharsets.UTF_8)); Stats stats = stream.stats(); System.out.println("bytes scanned: " + stats.bytesScanned()); System.out.println("bytes processed: " + stats.bytesProcessed()); System.out.println("bytes returned: " + stats.bytesReturned()); stream.close();- Parameters:
args- instance ofSelectObjectContentArgs- Returns:
SelectResponseStream- Contains filtered records and progress.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketEncryption
public void setBucketEncryption(SetBucketEncryptionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets encryption configuration of a bucket.Example:
minioClient.setBucketEncryption( SetBucketEncryptionArgs.builder().bucket("my-bucketname").config(config).build());- Parameters:
args-SetBucketEncryptionArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketEncryption
public SseConfiguration getBucketEncryption(GetBucketEncryptionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets encryption configuration of a bucket.Example:
SseConfiguration config = minioClient.getBucketEncryption( GetBucketEncryptionArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketEncryptionArgsobject.- Returns:
SseConfiguration- Server-side encryption configuration.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteBucketEncryption
public void deleteBucketEncryption(DeleteBucketEncryptionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes encryption configuration of a bucket.Example:
minioClient.deleteBucketEncryption( DeleteBucketEncryptionArgs.builder().bucket("my-bucketname").build());- Parameters:
args-DeleteBucketEncryptionArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getBucketTags
public Tags getBucketTags(GetBucketTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets tags of a bucket.Example:
Tags tags = minioClient.getBucketTags(GetBucketTagsArgs.builder().bucket("my-bucketname").build());- Parameters:
args-GetBucketTagsArgsobject.- Returns:
Tags- Tags.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setBucketTags
public void setBucketTags(SetBucketTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets tags to a bucket.Example:
Map<String, String> map = new HashMap<>(); map.put("Project", "Project One"); map.put("User", "jsmith"); minioClient.setBucketTags( SetBucketTagsArgs.builder().bucket("my-bucketname").tags(map).build());- Parameters:
args-SetBucketTagsArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteBucketTags
public void deleteBucketTags(DeleteBucketTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes tags of a bucket.Example:
minioClient.deleteBucketTags(DeleteBucketTagsArgs.builder().bucket("my-bucketname").build());- Parameters:
args-DeleteBucketTagsArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
getObjectTags
public Tags getObjectTags(GetObjectTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Gets tags of an object.Example:
Tags tags = minioClient.getObjectTags( GetObjectTagsArgs.builder().bucket("my-bucketname").object("my-objectname").build());- Parameters:
args-GetObjectTagsArgsobject.- Returns:
Tags- Tags.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
setObjectTags
public void setObjectTags(SetObjectTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Sets tags to an object.Example:
Map<String, String> map = new HashMap<>(); map.put("Project", "Project One"); map.put("User", "jsmith"); minioClient.setObjectTags( SetObjectTagsArgs.builder() .bucket("my-bucketname") .object("my-objectname") .tags((map) .build());- Parameters:
args-SetObjectTagsArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
deleteObjectTags
public void deleteObjectTags(DeleteObjectTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Deletes tags of an object.Example:
minioClient.deleteObjectTags( DeleteObjectTags.builder().bucket("my-bucketname").object("my-objectname").build());- Parameters:
args-DeleteObjectTagsArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
uploadSnowballObjects
public ObjectWriteResponse uploadSnowballObjects(UploadSnowballObjectsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException Uploads multiple objects in a single put call. It is done by creating intermediate TAR file optionally compressed which is uploaded to S3 service.Example:
// Upload snowball objects. List<SnowballObject> objects = new ArrayList<SnowballObject>(); objects.add( new SnowballObject( "my-object-one", new ByteArrayInputStream("hello".getBytes(StandardCharsets.UTF_8)), 5, null)); objects.add( new SnowballObject( "my-object-two", new ByteArrayInputStream("java".getBytes(StandardCharsets.UTF_8)), 4, null)); minioClient.uploadSnowballObjects( UploadSnowballObjectsArgs.builder().bucket("my-bucketname").objects(objects).build());- Parameters:
args-UploadSnowballObjectsArgsobject.- Throws:
ErrorResponseException- thrown to indicate S3 service returned an error response.InsufficientDataException- thrown to indicate not enough data available in InputStream.InternalException- thrown to indicate internal library error.InvalidKeyException- thrown to indicate missing of HMAC SHA-256 library.InvalidResponseException- thrown to indicate S3 service returned invalid or no error response.IOException- thrown to indicate I/O error on S3 operation.NoSuchAlgorithmException- thrown to indicate missing of MD5 or SHA-256 digest library.XmlParserException- thrown to indicate XML parsing error.ServerException
-
builder
-