Java Client API Reference Slack

Initialize MinIO Client object.

MinIO

MinioClient minioClient = new MinioClient("https://play.min.io",
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");

AWS S3

MinioClient s3Client = new MinioClient("https://s3.amazonaws.com",
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");
Bucket operations Object operations
bucketExists composeObject
deleteBucketEncryption copyObject
deleteBucketLifeCycle deleteObjectTags
deleteBucketTags disableObjectLegalHold
disableVersioning enableObjectLegalHold
enableVersioning getObject
getBucketEncryption getObjectRetention
getBucketLifeCycle getObjectTags
getBucketNotification getObjectUrl
getBucketPolicy getPresignedObjectUrl
getBucketTags isObjectLegalHoldEnabled
getDefaultRetention listObjects
listBuckets presignedGetObject
listenBucketNotification presignedPostPolicy
listIncompleteUploads presignedPutObject
makeBucket putObject
removeAllBucketNotification removeObject
removeBucket removeObjects
removeIncompleteUpload selectObjectContent
setBucketEncryption setObjectRetention
setBucketLifeCycle setObjectTags
setBucketNotification statObject
setBucketPolicy
setBucketTags
setDefaultRetention

1. Constructors

public MinioClient(String endpoint) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given endpoint using anonymous access.
public MinioClient(URL url) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given url using anonymous access.
public MinioClient(okhttp3.HttpUrl url) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given HttpUrl object using anonymous access.
public MinioClient(String endpoint, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given endpoint, access key and secret key.
public MinioClient(String endpoint, int port, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given endpoint, port, access key and secret key using secure (HTTPS) connection.
public MinioClient(String endpoint, String accessKey, String secretKey, boolean secure) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given endpoint, access key and secret key using secure (HTTPS) connection.
public MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object using given endpoint, port, access key, secret key and secure option.
public MinioClient(okhttp3.HttpUrl url, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given URL object, access key and secret key.
public MinioClient(URL url, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given URL object, access key and secret key.
public MinioClient(String endpoint, String accessKey, String secretKey, String region) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object with given URL object, access key and secret key.
public MinioClient(String endpoint, int port, String accessKey, String secretKey, String region, boolean secure) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object using given endpoint, port, access key, secret key, region and secure option.
public MinioClient(String endpoint, Integer port, String accessKey, String secretKey, String region, Boolean secure, okhttp3.OkHttpClient httpClient) throws InvalidEndpointException, InvalidPortException [Javadoc]
Creates MinIO client object using given endpoint, port, access key, secret key, region and secure option.

Parameters

Parameter Type Description
endpoint String Endpoint is an URL, domain name, IPv4 address or IPv6 address of S3 service.
Examples:
https://s3.amazonaws.com
https://play.min.io
https://play.min.io:9000
localhost
play.min.io
url URL Endpoint as URL object.
url okhttp3.HttpUrl Endpoint as okhttp3.HttpUrl object.
port int (Optional) TCP/IP port number. 80 and 443 are used as defaults for HTTP and HTTPS.
accessKey String (Optional) Access key (aka user ID) of your account in S3 service.
secretKey String (Optional) Secret Key (aka password) of your account in S3 service.
secure boolean (Optional) Flag to indicate to use secure connection to S3 service or not.
region String (Optional) Region name of buckets in S3 service.
httpClient okhttp3.OkHttpClient (Optional) Custom HTTP client object.

Example

MinIO

// 1. Create client to S3 service 'play.min.io' at port 443 with TLS security
// for anonymous access.
MinioClient minioClient = new MinioClient("https://play.min.io");

// 2. Create client to S3 service 'play.min.io' at port 443 with TLS security
// using URL object for anonymous access.
MinioClient minioClient = new MinioClient(new URL("https://play.min.io"));

// 3. Create client to S3 service 'play.min.io' at port 9000 with TLS security
// using okhttp3.HttpUrl object for anonymous access.
MinioClient minioClient = new MinioClient(new HttpUrl.parse("https://play.min.io:9000"));

// 4. Create client to S3 service 'play.min.io' at port 443 with TLS security
// for authenticated access.
MinioClient minioClient = new MinioClient("https://play.min.io",
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");

// 5. Create client to S3 service 'play.min.io' at port 9000 with non-TLS security
// for authenticated access.
MinioClient minioClient = new MinioClient("play.min.io", 9000,
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");

// 6. Create client to S3 service 'play.min.io' at port 9000 with TLS security
// for authenticated access.
MinioClient minioClient = new MinioClient("play.min.io", 9000,
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true);

// 7. Create client to S3 service 'play.min.io' at port 443 with TLS security
// using URL object for authenticated access.
MinioClient minioClient = new MinioClient(new URL("https://play.min.io"),
     "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");

// 8. Create client to S3 service 'play.min.io' at port 443 with TLS security
// using okhttp3.HttpUrl object for authenticated access.
MinioClient minioClient = new MinioClient(HttpUrl.parse("https://play.min.io"),
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");

// 9. Create client to S3 service 'play.min.io' at port 443 with TLS security
// and region 'us-west-1' for authenticated access.
MinioClient minioClient = new MinioClient("https://play.min.io",
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", "us-west-1");

// 10. Create client to S3 service 'play.min.io' at port 9000 with TLS security
// and region 'eu-east-1' for authenticated access.
MinioClient minioClient = new MinioClient("play.min.io", 9000,
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", "eu-east-1", true);

// 11. Create client to S3 service 'play.min.io' at port 9000 with TLS security,
// region 'eu-east-1' and custom HTTP client for authenticated access.
MinioClient minioClient = new MinioClient("play.min.io", 9000,
    "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", "eu-east-1",
    true, customHttpClient);

AWS S3

// 1. Create client to S3 service 's3.amazonaws.com' at port 443 with TLS security
// for anonymous access.
MinioClient s3Client = new MinioClient("https://s3.amazonaws.com");

// 2. Create client to S3 service 's3.amazonaws.com' at port 443 with TLS security
// using URL object for anonymous access.
MinioClient minioClient = new MinioClient(new URL("https://s3.amazonaws.com"));

// 3. Create client to S3 service 's3.amazonaws.com' at port 9000 with TLS security
// using okhttp3.HttpUrl object for anonymous access.
MinioClient s3Client = new MinioClient(new HttpUrl.parse("https://s3.amazonaws.com"));

// 4. Create client to S3 service 's3.amazonaws.com' at port 80 with TLS security
// for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");

// 5. Create client to S3 service 's3.amazonaws.com' at port 443 with non-TLS security
// for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com", 433, "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");

// 6. Create client to S3 service 's3.amazonaws.com' at port 80 with non-TLS security
// for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com",
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", false);

// 7. Create client to S3 service 's3.amazonaws.com' at port 80 with TLS security
// for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com", 80,
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true);

// 8. Create client to S3 service 's3.amazonaws.com' at port 80 with non-TLS security
// using URL object for authenticated access.
MinioClient s3Client = new MinioClient(new URL("s3.amazonaws.com"),
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");

// 9. Create client to S3 service 's3.amazonaws.com' at port 80 with non-TLS security
// using okhttp3.HttpUrl object for authenticated access.
MinioClient s3Client = new MinioClient(HttpUrl.parse("s3.amazonaws.com"),
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");

// 10. Create client to S3 service 's3.amazonaws.com' at port 80 with non-TLS security
// and region 'us-west-1' for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com",
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", "us-west-1");

// 11. Create client to S3 service 's3.amazonaws.com' at port 443 with TLS security
// and region 'eu-west-2' for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com", 443,
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", "eu-west-2", true);

// 12. Create client to S3 service 's3.amazonaws.com' at port 443 with TLS security,
// region 'eu-central-1' and custom HTTP client for authenticated access.
MinioClient s3Client = new MinioClient("s3.amazonaws.com", 443,
    "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", "eu-central-1", true, customHttpClient);

Common Exceptions

All APIs throw below exceptions in addition to specific to API.

Exception Cause
ErrorResponseException Thrown to indicate S3 service returned an error response.
IllegalArgumentException Throws to indicate invalid argument passed.
InsufficientDataException Thrown to indicate not enough data available in InputStream.
InternalException Thrown to indicate internal library error.
InvalidBucketNameException Thrown to indicate invalid bucket name passed.
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.

2. Bucket operations

bucketExists(String bucketName)

public boolean bucketExists(String bucketName) [Javadoc]

Checks if a bucket exists.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Returns
boolean - True if the bucket exists.

Example

// Check whether 'my-bucketname' exists or not.
boolean found = minioClient.bucketExists("my-bucketname");
if (found) {
  System.out.println("my-bucketname exists");
} else {
  System.out.println("my-bucketname does not exist");
}

deleteBucketEncryption(DeleteBucketEncryptionArgs args)

private void deleteBucketEncryption(DeleteBucketEncryptionArgs args) [Javadoc]

Deletes encryption configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:----------|:-------------------------------|:------------|
| args | DeleteBucketEncryptionArgs | Arguments. |

Example

minioClient.deleteBucketEncryption(
    DeleteBucketEncryptionArgs.builder().bucket("my-bucketname").build());

deleteBucketLifeCycle(String bucketName)

private void deleteBucketLifeCycle(String bucketName) [Javadoc]

Deletes life cycle configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Example

minioClient.deleteBucketLifeCycle("my-bucketname");

deleteBucketTags(DeleteBucketTagsArgs args)

private void deleteBucketTags(DeleteBucketTagsArgs args) [Javadoc]

Deletes tags of a bucket.

Parameters
| Parameter | Type | Description |
|:----------|:-------------------------|:------------|
| args | DeleteBucketTagsArgs | Arguments. |

Example

minioClient.deleteBucketTags(DeleteBucketTagsArgs.builder().bucket("my-bucketname").build());

disableVersioning(DisableVersioningArgs args)

public void disableVersioning(DisableVersioningArgs args) [Javadoc]

Disables object versioning feature in a bucket.

Parameters

Parameter Type Description
args DisableVersioningArgs Arguments.

Example

minioClient.disableVersioning(DisableVersioningArgs.builder().bucket("my-bucket").build());

enableVersioning(EnableVersioningArgs args)

public void enableVersioning(EnableVersioningArgs args) [Javadoc]

Enables object versioning feature in a bucket.

Parameters

Parameter Type Description
args EnableVersioningArgs Arguments.

Example

minioClient.enableVersioning(EnableVersioningArgs.builder().bucket("my-bucket").build());

getBucketEncryption(GetBucketEncryptionArgs args)

public SseConfiguration getBucketEncryption(GetBucketEncryptionArgs args) [Javadoc]

Gets encryption configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:----------|:----------------------------|:------------|
| args | GetBucketEncryptionArgs | Arguments. |

Returns
SseConfiguration - Server-side encryption configuration.

Example

SseConfiguration config =
    minioClient.getBucketEncryption(
        GetBucketEncryptionArgs.builder().bucket("my-bucketname").build());

getBucketLifeCycle(String bucketName)

public String getBucketLifeCycle(String bucketName) [Javadoc]

Gets life cycle configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Returns
String - Life cycle configuration as XML string.

Example

String lifecycle = minioClient.getBucketLifecycle("my-bucketname");
System.out.println("Life cycle settings: " + lifecycle);

getBucketNotification(String bucketName)

public NotificationConfiguration getBucketNotification(String bucketName) [Javadoc]

Gets notification configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Returns
NotificationConfiguration - Notification configuration.

Example

NotificationConfiguration config = minioClient.getBucketNotification("my-bucketname");

getBucketPolicy(String bucketName)

public String getBucketPolicy(String bucketName) [Javadoc]

Gets bucket policy configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Returns
String - Bucket policy configuration as JSON string.

Example

String config = minioClient.getBucketPolicy("my-bucketname");

getBucketTags(GetBucketTagsArgs args)

public Tags getBucketTags(GetBucketTagsArgs args) [Javadoc]

Gets tags of a bucket.

Parameters
| Parameter | Type | Description |
|:----------|:----------------------|:------------|
| args | GetBucketTagsArgs | Arguments. |

Returns
Tags - tags.

Example

Tags tags = minioClient.getBucketTags(GetBucketTagsArgs.builder().bucket("my-bucketname").build());

getDefaultRetention(String bucketName)

public ObjectLockConfiguration getDefaultRetention(String bucketName) [Javadoc]

Gets default object retention in a bucket.

Parameters

Parameter Type Description
bucketName String Name of the bucket.
Returns
ObjectLockConfiguration - Default retention configuration.

Example

// bucket must be created with object lock enabled.
minioClient.makeBucket("my-bucketname", null, true);
ObjectLockConfiguration config = minioClient.getDefaultRetention("my-bucketname");
System.out.println("Mode: " + config.mode());
System.out.println("Duration: " + config.duration().duration() + " " + config.duration().unit());

listBuckets()

public List<Bucket> listBuckets() [Javadoc]

Lists bucket information of all buckets.

Returns
List<Bucket> - List of bucket information.

Example

List<Bucket> bucketList = minioClient.listBuckets();
for (Bucket bucket : bucketList) {
  System.out.println(bucket.creationDate() + ", " + bucket.name());
}

listenBucketNotification(String bucketName, String prefix, String suffix, String[] events)

public CloseableIterator<Result<NotificationRecords>> listenBucketNotification(String bucketName, String prefix, String suffix, String[] events) [Javadoc]

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.

Parameters
| Parameter | Type | Description |
|:---------------|:-----------|:--------------------------------------------|
| bucketName | String | Name of the bucket. |
| prefix | String | Listen events of object starts with prefix. |
| suffix | String | Listen events of object ends with suffix. |
| events | String[] | Events to listen. |

Returns
CloseableIterator<Result<NotificationRecords>> - Lazy closable iterator contains event records.

Example

String[] events = {"s3:ObjectCreated:*", "s3:ObjectAccessed:*"};
try (CloseableIterator<Result<NotificationInfo>> ci =
    minioClient.listenBucketNotification("bcketName", "", "", events)) {
  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());
    }
  }
}

listIncompleteUploads(String bucketName)

public Iterable<Result<Upload>> listIncompleteUploads(String bucketName) [Javadoc]

Lists incomplete object upload information of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Returns
Iterable<Result<Upload>> - Lazy iterator contains object upload information.

Example

Iterable<Result<Upload>> results = minioClient.listIncompleteUploads("my-bucketname");
for (Result<Upload> result : results) {
  Upload upload = result.get();
  System.out.println(upload.uploadId() + ", " + upload.objectName());
}

listIncompleteUploads(String bucketName, String prefix)

public Iterable<Result<Upload>> listIncompleteUploads(String bucketName, String prefix) [Javadoc]

Lists incomplete object upload information of a bucket for prefix.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------------------|
| bucketName | String | Name of the bucket. |
| prefix | String | Object name starts with prefix. |

Returns
Iterable<Result<Upload>> - Lazy iterator contains object upload information.

Example

Iterable<Result<Upload>> myObjects = minioClient.listIncompleteUploads("my-bucketname", "my-obj");
for (Result<Upload> result : results) {
  Upload upload = result.get();
  System.out.println(upload.uploadId() + ", " + upload.objectName());
}

listIncompleteUploads(String bucketName, String prefix, boolean recursive)

public Iterable<Result<Upload>> listIncompleteUploads(String bucketName, String prefix, boolean recursive) [Javadoc]

Lists incomplete object upload information of a bucket for prefix recursively.

Parameters
| Param | Type | Description |
|:---------------|:----------|:-----------------------------------------------------|
| bucketName | String | Name of the bucket. |
| prefix | String | Object name starts with prefix. |
| recursive | boolean | List recursively than directory structure emulation. |

Returns
Iterable<Result<Upload>> - Lazy iterator contains object upload information.

Example

Iterable<Result<Upload>> myObjects = minioClient.listIncompleteUploads("my-bucketname", "my-obj", true);
for (Result<Upload> result : results) {
  Upload upload = result.get();
  System.out.println(upload.uploadId() + ", " + upload.objectName());
}

listObjects(ListObjectsArgs args)

public Iterable<Result<Item>> listObjects(ListObjectsArgs args) [Javadoc]

Lists object information of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| args | ListObjectsArgs | Arguments to list objects |

Returns
Iterable<Result<Item>> - Lazy iterator contains object information.

Example

Iterable<Result<Item>> results = minioClient.listObjects(
  ListObjectsArgs.builder()
    .bucket("my-bucketname")
    .includeUserMetadata(true)
    .startAfter("start-after-entry")
    .prefix("my-obj")
    .maxKeys(100)
    .fetchOwner(true)
);
for (Result<Item> result : results) {
  Item item = result.get();
  System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}

makeBucket(MakeBucketArgs args)

public void makeBucket(MakeBucketArgs args) [Javadoc]

Creates a bucket with given region and object lock feature enabled.

Parameters

Parameter Type Description
args MakeBucketArgs Arguments to create bucket

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());

removeAllBucketNotification(String bucketName)

public void removeAllBucketNotification(String bucketName) [Javadoc]

Removes notification configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------|
| bucketName | String | Name of the bucket. |

Example

minioClient.removeAllBucketNotification("my-bucketname");

removeBucket(RemoveBucketArgs args)

public void removeBucket(RemoveBucketArgs args) [Javadoc]

Removes an empty bucket.

Parameters

Parameter Type Description
args RemoveBucketArgs Arguments.

Example

minioClient.removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build());

removeIncompleteUpload(String bucketName, String objectName)

public void removeIncompleteUpload(String bucketName, String objectName) [Javadoc]

Removes incomplete uploads of an object.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |

Example

minioClient.removeIncompleteUpload("my-bucketname", "my-objectname");

setBucketEncryption(SetBucketEncryptionArgs args)

public void setBucketEncryption(SetBucketEncryptionArgs args) [Javadoc]

Sets encryption configuration of a bucket.

Parameters
| Parameter | Type | Description |
|:----------|:----------------------------|:------------|
| args | SetBucketEncryptionArgs | Arguments. |

Example

minioClient.setBucketEncryption(
    SetBucketEncryptionArgs.builder().bucket("my-bucketname").config(config).build());

setBucketLifeCycle(String bucketName, String lifeCycle)

public void setBucketLifeCycle(String bucketName, String lifeCycle) [Javadoc]

Sets life cycle configuration to a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------------------|
| bucketName | String | Name of the bucket. |
| lifeCycle | String | Life cycle configuraion as XML string. |

Example

// Lets consider variable 'lifeCycleXml' contains below XML String;
// <LifecycleConfiguration>
//   <Rule>
//     <ID>expire-bucket</ID>
//     <Prefix></Prefix>
//     <Status>Enabled</Status>
//     <Expiration>
//       <Days>365</Days>
//     </Expiration>
//   </Rule>
// </LifecycleConfiguration>
//
minioClient.setBucketLifecycle("my-bucketname", lifeCycleXml);

setBucketNotification(String bucketName, NotificationConfiguration notificationConfiguration)

public void setBucketNotification(String bucketName, NotificationConfiguration notificationConfiguration) [Javadoc]

Sets notification configuration to a bucket.

Parameters

Parameter Type Description
bucketName String Name of the bucket.
notificationConfiguration NotificationConfiguration Notification configuration to be set.

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("my-bucketname", config);

setBucketPolicy(String bucketName, String policy)

public void setBucketPolicy(String bucketName, String policy) [Javadoc]

Sets bucket policy configuration to a bucket.

Parameters

Parameter Type Description
bucketName String Name of the bucket.
policy String Bucket policy configuration as JSON string.

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("my-bucketname", policyJson);

setBucketTags(SetBucketTagsArgs args)

public void setBucketTags(SetBucketTagsArgs args) [Javadoc]

Sets tags to a bucket.

Parameters

Parameter Type Description
args SetBucketTagsArgs Arguments.

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());

setDefaultRetention(String bucketName, ObjectLockConfiguration config)

public void setDefaultRetention(String bucketName, ObjectLockConfiguration config) [Javadoc]

Sets default object retention in a bucket.

Parameters
| Parameter | Type | Description |
|:---------------|:----------------------------|:---------------------------|
| bucketName | String | Name of the bucket. |
| config | ObjectLockConfiguration | Object lock Configuration. |

Example

ObjectLockConfiguration config =
    new ObjectLockConfiguration(RetentionMode.COMPLIANCE, new RetentionDurationDays(100));
minioClient.setDefaultRetention("my-bucketname", config);

3. Object operations

composeObject(String bucketName, String objectName, List sources, Map headerMap, ServerSideEncryption sse)

public void composeObject(String bucketName, String objectName, List<ComposeSource> sources, Map<String,String> headerMap, ServerSideEncryption sse) [Javadoc]

Creates an object by combining data from different source objects using server-side copy.

Parameters
| Param | Type | Description |
|:---------------|:-------------------------|:-----------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name to be created. |
| sources | List<ComposeSource> | List of compose sources. |
| headerMap | Map | (Optional) User metadata. |
| sse | ServerSideEncryption | (Optional) Server-side encryption. |

Example

List<ComposeSource> sourceObjectList = new ArrayList<ComposeSource>();
sourceObjectList.add(new ComposeSource("my-job-bucket", "my-objectname-part-one"));
sourceObjectList.add(new ComposeSource("my-job-bucket", "my-objectname-part-two"));
sourceObjectList.add(new ComposeSource("my-job-bucket", "my-objectname-part-three"));

// Create my-bucketname/my-objectname by combining source object list.
minioClient.composeObject("my-bucketname", "my-objectname", sourceObjectList, null, null);

// Create my-bucketname/my-objectname with user metadata by combining source object list.
minioClient.composeObject("my-bucketname", "my-objectname", sourceObjectList, userMetadata, null);

// Create my-bucketname/my-objectname with user metadata and server-side encryption by combining
// source object list.
minioClient.composeObject("my-bucketname", "my-objectname", sourceObjectList, userMetadata, sse);

copyObject(String bucketName, String objectName, Map headerMap, ServerSideEncryption sse, String srcBucketName, String srcObjectName, ServerSideEncryption srcSse, CopyConditions copyConditions)

public void copyObject(String bucketName, String objectName, Map<String,String> headerMap, ServerSideEncryption sse, String srcBucketName, String srcObjectName, ServerSideEncryption srcSse, CopyConditions copyConditions) [Javadoc]

Creates an object by server-side copying data from another object.

Parameters
| Parameter | Type | Description |
|:-------------------|:-------------------------|:---------------------------------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name to be created. |
| headerMap | Map | (Optional) User metadata. |
| sse | ServerSideEncryption | (Optional) Server-side encryption. |
| srcBucketName | String | Source bucket name. |
| srcObjectName | String | (Optional) Source object name. |
| srcSse | ServerSideEncryption | (Optional) SSE-C type server-side encryption of source object. |
| copyConditions | CopyConditions | (Optional) Conditiions to be used in copy operation. |

Example

// Copy data from my-source-bucketname/my-objectname to my-bucketname/my-objectname.
minioClient.copyObject("my-bucketname", "my-objectname", null, null, "my-source-bucketname", null, null,
    null);

// Copy data from my-source-bucketname/my-source-objectname to my-bucketname/my-objectname.
minioClient.copyObject("my-bucketname", "my-objectname", null, null, "my-source-bucketname",
    "my-source-objectname", null, null);

// Copy data from my-source-bucketname/my-objectname to my-bucketname/my-objectname by server-side encryption.
minioClient.copyObject("my-bucketname", "my-objectname", null, sse, "my-source-bucketname", null, null, null);

// Copy data from SSE-C encrypted my-source-bucketname/my-objectname to my-bucketname/my-objectname.
minioClient.copyObject("my-bucketname", "my-objectname", null, null, "my-source-bucketname", null, srcSsec,
    null);

// Copy data from my-source-bucketname/my-objectname to my-bucketname/my-objectname with user metadata and
// copy conditions.
minioClient.copyObject("my-bucketname", "my-objectname", headers, null, "my-source-bucketname", null, null,
    conditions);

deleteObjectTags(DeleteObjectTagsArgs args)

private void deleteObjectTags(DeleteObjectTagsArgs args) [Javadoc]

Deletes tags of an object.

Parameters
| Parameter | Type | Description |
|:----------|:-------------------------|:------------|
| args | DeleteObjectTagsArgs | Arguments. |

Example

minioClient.deleteObjectTags(
    DeleteObjectArgs.builder().bucket("my-bucketname").object("my-objectname").build());

disableObjectLegalHold(String bucketName, String objectName, String versionId)

public void disableObjectLegalHold(String bucketName, String objectName, String versionId) [Javadoc]

Disables legal hold on an object.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:--------------------------|
| bucketName | String | Bucket name. |
| objectName | String | Object name. |
| versionId | String | Version ID of the object. |

Example

minioClient.disableObjectLegalHold("my-bucketname", "my-objectName", null);

enableObjectLegalHold(String bucketName, String objectName, String versionId)

public void enableObjectLegalHold(String bucketName, String objectName, String versionId) [Javadoc]

Enables legal hold on an object.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| versionId | String | Version ID of the object. |

Example

minioClient.enableObjectLegalHold("my-bucketname", "my-objectname", null);

getObject(String bucketName, String objectName)

public InputStream getObject(String bucketName, String objectName) [Javadoc]

Gets data of an object. Returned InputStream must be closed after use to release network resources.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |

Returns
InputStream - Contains object data.

Example

try (InputStream stream = minioClient.getObject("my-bucketname", "my-objectname")) {
  // Read data from stream
}

getObject(String bucketName, String objectName, long offset)

public InputStream getObject(String bucketName, String objectName, long offset) [Javadoc]

Gets data from offset of an object. Returned InputStream must be closed after use to release network resources.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| offset | long | Start byte position of object data. |

Returns
InputStream - Contains object data.

Example

try (InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", 1024L)) {
  // Read data from stream
}

getObject(String bucketName, String objectName, long offset, Long length)

public InputStream getObject(String bucketName, String objectName, long offset, Long length) [Javadoc]

Gets data from offset to length of an object. Returned {@link InputStream} must be closed after use to release network resources.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:-------------------------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| offset | long | Start byte position of object data. |
| length | Long | (Optional) Number of bytes of object data from offset. |

Returns
InputStream - Contains object data.

Example

try (InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", 1024L, 4096L)) {
  // Read data from stream
}

getObject(String bucketName, String objectName, ServerSideEncryption sse)

public InputStream getObject(String bucketName, String objectName, ServerSideEncryption sse) [Javadoc]

Gets data of a SSE-C encrypted object. Returned {@link InputStream} must be closed after use to release network resources.

Parameters
| Parameter | Type | Description |
|:---------------|:-------------------------|:-----------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| sse | ServerSideEncryption | SSE-C type server-side encryption. |

Returns
InputStream - Contains object data.

Example

try (InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", ssec)) {
  // Read data from stream
}

getObject(String bucketName, String objectName, Long offset, Long length, ServerSideEncryption sse)

public InputStream getObject(String bucketName, String objectName, Long offset, Long length, ServerSideEncryption sse) [Javadoc]

Gets data from offset to length of a SSE-C encrypted object. Returned {@link InputStream} must be closed after use to release network resources.

Parameters
| Parameter | Type | Description |
|:---------------|:-------------------------|:-------------------------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| offset | Long | (Optional) Start byte position of object data. |
| length | Long | (Optional) Number of bytes of object data from offset. |
| sse | ServerSideEncryption | (Optional) Server-side encryption. |

Returns
InputStream - Contains object data.

Example

try (InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", 1024L, 4096L, ssec)) {
  // Read data from stream
}

getObject(String bucketName, String objectName, String fileName)

public void getObject(String bucketName, String objectName, String fileName) [Javadoc]

Downloads data of an object to file.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| fileName | String | Name of the file. |

Example

minioClient.getObject("my-bucketname", "my-objectname", "my-object-file");

getObject(String bucketName, String objectName, ServerSideEncryption sse, String fileName)

public void getObject(String bucketName, String objectName, ServerSideEncryption sse, String fileName) [Javadoc]

Downloads server-side encrypted object in bucket to given file name.

Parameters
| Parameter | Type | Description |
|:---------------|:-------------------------|:-----------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| sse | ServerSideEncryption | SSE-C type server-side encryption. |
| fileName | String | Name of the file. |

Example

minioClient.getObject("my-bucketname", "my-objectname", ssec, "my-object-file");

getObjectRetention(String bucketName, String objectName, String versionId)

public Retention getObjectRetention(String bucketName, String objectName, String versionId) [Javadoc]

Gets retention configuration of an object.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| versionId | String | Version ID of the object. |

Returns
Retention - Object retention configuration.

Example

Retention retention = minioClient.getObjectRetention("my-bucketname", "my-objectname", null);
System.out.println("mode: " + retention.mode() + "until: " + retention.retainUntilDate());

getObjectTags(GetObjectTagsArgs args)

public Tags getObjectTags(GetObjectTagsArgs args) [Javadoc]

Gets tags of an object.

Parameters
| Parameter | Type | Description |
|:----------|:----------------------|:------------|
| args | GetObjectTagsArgs | Arguments. |

Returns
Tags - tags.

Example

Tags tags = minioClient.getObjectTags(
    GetObjectTagsArgs.builder().bucket("my-bucketname").object("my-objectname").build());

getObjectUrl(String bucketName, String objectName)

public String getObjectUrl(String bucketName, String objectName) [Javadoc]

Gets URL of an object useful when this object has public read access.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |

Returns
String - URL string.

Example

String url = minioClient.getObjectUrl("my-bucketname", "my-objectname");
System.out.println("my-bucketname/my-objectname can be downloaded by " + url);

getPresignedObjectUrl(Method method, String bucketName, String objectName, Integer expires, Map reqParams)

public String getPresignedObjectUrl(Method method, String bucketName, String objectName, Integer expires, Map<String,String> reqParams) [Javadoc]

Gets presigned URL of an object for HTTP method, expiry time and custom request parameters.

Parameters
| Parameter | Type | Description |
|:---------------|:---------------------|:---------------------------------------|
| method | Method | HTTP method to generate presigned URL. |
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| expires | Integer | Expiry in seconds; defaults to 7 days. |
| reqParams | Map | Request parameters to override. |

Returns
String - URL string.

Example

String url = minioClient.getPresignedObjectUrl(Method.DELETE, "my-bucketname", "my-objectname", 24 * 60 * 60,
    reqParams);

isObjectLegalHoldEnabled(String bucketName, String objectName, String versionId)

public boolean isObjectLegalHoldEnabled(String bucketName, String objectName, String versionId) [Javadoc]

Returns true if legal hold is enabled on an object.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| versionId | String | Version ID of the object. |

Returns
boolean - True if legal hold is enabled.

Example

boolean status = minioClient.isObjectLegalHoldEnabled("my-bucketname", "my-objectname", null);
if (status) {
  System.out.println("Legal hold is on");
else {
  System.out.println("Legal hold is off");
}

presignedGetObject(String bucketName, String objectName)

public String presignedGetObject(String bucketName, String objectName) [Javadoc]

Gets presigned URL of an object to download its data for 7 days.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |

Returns
String - URL string to download the object.

Example

String url = minioClient.presignedGetObject("my-bucketname", "my-objectname");

presignedGetObject(String bucketName, String objectName, Integer expires)

public String presignedGetObject(String bucketName, String objectName, Integer expires) [Javadoc]

Gets presigned URL of an object to download its data for expiry time.

Parameters
| Parameter | Type | Description |
|:---------------|:----------|:----------------------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| expires | Integer | Expiry in seconds. Default expiry is set to 7 days. |

Returns
String - URL string to download the object.

Example

// Get presigned URL to download my-objectname data with one day expiry.
String url = minioClient.presignedGetObject("my-bucketname", "my-objectname", 24 * 60 * 60);

presignedGetObject(String bucketName, String objectName, Integer expires, Map reqParams)

public String presignedGetObject(String bucketName, String objectName, Integer expires, Map<String,String> reqParams) [Javadoc]

Gets presigned URL of an object to download its data for expiry time and request parameters.

Parameters
| Parameter | Type | Description |
|:---------------|:---------------------|:---------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| expires | Integer | Expiry in seconds; defaults to 7 days. |
| reqParams | Map | Request parameters to override. |

Returns
String - URL string to download the object.

Example

// Get presigned URL to download my-objectname data with one day expiry and request parameters.
String url = minioClient.presignedGetObject("my-bucketname", "my-objectname", 24 * 60 * 60, reqParams);

presignedPostPolicy(PostPolicy policy)

public Map<String,String> presignedPostPolicy(PostPolicy policy) [Javadoc]

Gets form-data of PostPolicy of an object to upload its data using POST method.

Parameters
| Parameter | Type | Description |
|:-----------|:---------------|:--------------------------|
| policy | PostPolicy | Post policy of an object. |

Returns
Map - Contains form-data to upload an object using POST method.

Example

PostPolicy policy = new PostPolicy("my-bucketname", "my-objectname", ZonedDateTime.now().plusDays(7));

// 'my-objectname' should be 'image/png' content type
policy.setContentType("image/png");

// set success action status to 201 to receive XML document
policy.setSuccessActionStatus(201);

Map<String,String> formData = minioClient.presignedPostPolicy(policy);

// Print curl command to be executed by anonymous user to upload /tmp/userpic.png.
System.out.print("curl -X POST ");
for (Map.Entry<String,String> entry : formData.entrySet()) {
  System.out.print(" -F " + entry.getKey() + "=" + entry.getValue());
}
System.out.println(" -F file=@/tmp/userpic.png https://play.min.io/my-bucketname");

presignedPutObject(String bucketName, String objectName)

public String presignedPutObject(String bucketName, String objectName) [Javadoc]

Gets presigned URL of an object to upload data for 7 days.

Parameters
| Parameter | Type | Description |
|:---------------|:---------|:---------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |

Returns
String - URL string to upload an object.

Example

String url = minioClient.presignedPutObject("my-bucketname", "my-objectname");

presignedPutObject(String bucketName, String objectName, Integer expires)

public String presignedPutObject(String bucketName, String objectName, Integer expires) [Javadoc]

Gets presigned URL of an object to upload data for expiry time.

Parameters
| Parameter | Type | Description |
|:---------------|:----------|:---------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| expires | Integer | Expiry in seconds; defaults to 7 days. |

Returns
String - URL string to upload an object.

Example

// Get presigned URL to upload data to my-objectname with one day expiry.
String url = minioClient.presignedPutObject("my-bucketname", "my-objectname", 24 * 60 * 60);

putObject(String bucketName, String objectName, InputStream stream, PutObjectOptions options)

public void putObject(String bucketName, String objectName, InputStream stream, PutObjectOptions options) [Javadoc]

Uploads given stream as object in bucket by using given options.

Parameters
| Parameter | Type | Description |
|:---------------|:---------------------|:----------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| stream | InputStream | Stream contains object data. |
| options | PutObjectOptions | Options to be used during upload. |

Example

PutObjectOptions options = new PutObjectOptions(7003256, -1);
minioClient.putObject("my-bucketname", "my-objectname", stream, options);

putObject(String bucketName, String objectName, String filename, PutObjectOptions options)

public void putObject(String bucketName, String objectName, String filename, PutObjectOptions options) [Javadoc]

Uploads contents from a file as object in bucket using options.

Parameters
| Parameter | Type | Description |
|:---------------|:---------------------|:---------------------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| fileName | String | Name of file to upload. |
| options | PutObjectOptions | (Optional) Options to be used during upload. |

Example

minioClient.putObject("my-bucketname", "my-objectname", "my-filename", null);

removeObject(RemoveObjectArgs args)

public void removeObject(RemoveObjectArgs args) [Javadoc]

Removes an object.

Parameters
| Parameter | Type | Description |
|:----------|:---------------------|:------------|
| args | RemoveObjectArgs | Arguments. |

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());

removeObjects(String bucketName, Iterable objectNames)

public Iterable<Result<DeleteError>> removeObjects(String bucketName, Iterable<String> objectNames) [Javadoc]

Removes multiple objects lazily. Its required to iterate the returned Iterable to perform removal.

Parameters
| Parameter | Type | Description |
|:----------------|:-------------------|:-------------------------------|
| bucketName | String | Name of the bucket. |
| objectNames | Iterable | List of objects in the bucket. |

Returns
Iterable<Result<DeleteError>> - Lazy iterator contains object removal status.

Example

List<String> myObjectNames = new LinkedList<String>();
objectNames.add("my-objectname1");
objectNames.add("my-objectname2");
objectNames.add("my-objectname3");
Iterable<Result<DeleteError>> results = minioClient.removeObjects("my-bucketname", myObjectNames);
for (Result<DeleteError> result : results) {
  DeleteError error = errorResult.get();
  System.out.println("Error in deleting object " + error.objectName() + "; " + error.message());
}

selectObjectContent(String bucketName, String objectName, String sqlExpression, InputSerialization is, OutputSerialization os, boolean requestProgress, Long scanStartRange, Long scanEndRange, ServerSideEncryption sse)

public SelectResponseStream selectObjectContent(String bucketName, String objectName, String sqlExpression, InputSerialization is, OutputSerialization os, boolean requestProgress, Long scanStartRange, Long scanEndRange, ServerSideEncryption sse) [Javadoc]

Selects content of a object by SQL expression.

Parameters

Parameter Type Description
bucketName String Name of the bucket.
objectName String Object name in the bucket.
sqlExpression String SQL expression.
is InputSerialization Input specification of object data.
os OutputSerialization Output specification of result.
requestProgress boolean Flag to request progress information.
scanStartRange Long scan start range of the object.
scanEndRange Long scan end range of the object.
sse ServerSideEncryption SSE-C type server-side encryption.
Returns
SelectResponseStream - Contains filtered records and progress.

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("my-bucketname", "my-objectName", sqlExpression,
    is, os, true, null, null, null);

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();

setObjectRetention(String bucketName, String objectName, String versionId, Retention retention, boolean bypassGovernanceRetention)

public void setObjectLockRetention(String bucketName, String objectName, String versionId, Retention retention, boolean bypassGovernanceRetention) [Javadoc]

Sets retention configuration to an object.

Parameters
| Parameter | Type | Description |
|:------------------------------|:--------------|:--------------------------------|
| bucketName | String | Name of the bucket. |
| objectName | String | Object name in the bucket. |
| versionId | String | Version ID of the object. |
| config | Retention | Object retention configuration. |
| bypassGovernanceRetention | boolean | Bypass Governance retention. |

Example

Retention retention = new Retention(RetentionMode.COMPLIANCE, ZonedDateTime.now().plusYears(1));
minioClient.setObjectRetention("my-bucketname", "my-objectname", null, true, retention);

setObjectTags(SetObjectTagsArgs args)

public void setObjectTags(SetObjectTagsArgs args) [Javadoc]

Sets tags to an object.

Parameters

Parameter Type Description
args SetObjectTagsArgs Arguments.

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());

statObject(StatObjectArgs args)

public ObjectStat statObject(StatObjectArgs args) [Javadoc]

Gets object information and metadata of an object.

Parameters
| Parameter | Type | Description |
|:----------|:-------------------|:------------|
| args | StatObjectArgs | Arguments. |

Returns
ObjectStat - Populated object information and metadata.

Example

// Get information of an object.
ObjectStat objectStat =
    minioClient.statObject(
        StatObjectArgs.builder().bucket("my-bucketname").object("my-objectname").build());

// Get information of SSE-C encrypted object.
ObjectStat objectStat =
    minioClient.statObject(
        StatObjectArgs.builder()
            .bucket("my-bucketname")
            .object("my-objectname")
            .ssec(ssec)
            .build());

// Get information of a versioned object.
ObjectStat objectStat =
    minioClient.statObject(
        StatObjectArgs.builder()
            .bucket("my-bucketname")
            .object("my-objectname")
            .versionId("version-id")
            .build());

// Get information of a SSE-C encrypted versioned object.
ObjectStat objectStat =
    minioClient.statObject(
        StatObjectArgs.builder()
            .bucket("my-bucketname")
            .object("my-objectname")
            .versionId("version-id")
            .ssec(ssec)
            .build());

5. Explore Further