public class MinioClient extends Object
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();
| Modifier and Type | Class and Description |
|---|---|
static class |
MinioClient.Builder |
| Modifier | Constructor and Description |
|---|---|
protected |
MinioClient(MinioClient client) |
| Modifier and Type | Method and Description |
|---|---|
protected AbortMultipartUploadResponse |
abortMultipartUpload(String bucketName,
String region,
String objectName,
String uploadId,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
boolean |
bucketExists(BucketExistsArgs args)
Checks if a bucket exists.
|
static MinioClient.Builder |
builder() |
protected okhttp3.HttpUrl |
buildUrl(Method method,
String bucketName,
String objectName,
String region,
com.google.common.collect.Multimap<String,String> queryParamMap)
Build URL for given parameters.
|
protected ObjectWriteResponse |
completeMultipartUpload(String bucketName,
String region,
String objectName,
String uploadId,
Part[] parts,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
ObjectWriteResponse |
composeObject(ComposeObjectArgs args)
Creates an object by combining data from different source objects using server-side copy.
|
ObjectWriteResponse |
copyObject(CopyObjectArgs args)
Creates an object by server-side copying data from another object.
|
protected CreateMultipartUploadResponse |
createMultipartUpload(String bucketName,
String region,
String objectName,
com.google.common.collect.Multimap<String,String> headers,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
protected okhttp3.Request |
createRequest(okhttp3.HttpUrl url,
Method method,
okhttp3.Headers headers,
Object body,
int length,
Credentials creds)
Create HTTP request for given paramaters.
|
void |
deleteBucketEncryption(DeleteBucketEncryptionArgs args)
Deletes encryption configuration of a bucket.
|
void |
deleteBucketLifecycle(DeleteBucketLifecycleArgs args)
Deletes lifecycle configuration of a bucket.
|
void |
deleteBucketNotification(DeleteBucketNotificationArgs args)
Deletes notification configuration of a bucket.
|
void |
deleteBucketPolicy(DeleteBucketPolicyArgs args)
Deletes bucket policy configuration to a bucket.
|
void |
deleteBucketReplication(DeleteBucketReplicationArgs args)
Deletes bucket replication configuration from a bucket.
|
void |
deleteBucketTags(DeleteBucketTagsArgs args)
Deletes tags of a bucket.
|
void |
deleteObjectLockConfiguration(DeleteObjectLockConfigurationArgs args)
Deletes default object retention in a bucket.
|
protected DeleteObjectsResponse |
deleteObjects(String bucketName,
String region,
List<DeleteObject> objectList,
boolean quiet,
boolean bypassGovernanceMode,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
void |
deleteObjectTags(DeleteObjectTagsArgs args)
Deletes tags of an object.
|
void |
disableAccelerateEndpoint()
Disables accelerate endpoint for Amazon S3 endpoint.
|
void |
disableDualStackEndpoint()
Disables dual-stack endpoint for Amazon S3 endpoint.
|
void |
disableObjectLegalHold(DisableObjectLegalHoldArgs args)
Disables legal hold on an object.
|
void |
disableVirtualStyleEndpoint()
Disables virtual-style endpoint.
|
void |
downloadObject(DownloadObjectArgs args)
Downloads data of a SSE-C encrypted object to file.
|
void |
enableAccelerateEndpoint()
Enables accelerate endpoint for Amazon S3 endpoint.
|
void |
enableDualStackEndpoint()
Enables dual-stack endpoint for Amazon S3 endpoint.
|
void |
enableObjectLegalHold(EnableObjectLegalHoldArgs args)
Enables legal hold on an object.
|
void |
enableVirtualStyleEndpoint()
Enables virtual-style endpoint.
|
protected okhttp3.Response |
execute(Method method,
BaseArgs args,
com.google.common.collect.Multimap<String,String> headers,
com.google.common.collect.Multimap<String,String> queryParams,
Object body,
int length)
Execute HTTP request for given args and parameters.
|
protected okhttp3.Response |
execute(Method method,
String bucketName,
String objectName,
String region,
okhttp3.Headers headers,
com.google.common.collect.Multimap<String,String> queryParamMap,
Object body,
int length)
Execute HTTP request for given parameters.
|
SseConfiguration |
getBucketEncryption(GetBucketEncryptionArgs args)
Gets encryption configuration of a bucket.
|
LifecycleConfiguration |
getBucketLifecycle(GetBucketLifecycleArgs args)
Gets lifecycle configuration of a bucket.
|
NotificationConfiguration |
getBucketNotification(GetBucketNotificationArgs args)
Gets notification configuration of a bucket.
|
String |
getBucketPolicy(GetBucketPolicyArgs args)
Gets bucket policy configuration of a bucket.
|
ReplicationConfiguration |
getBucketReplication(GetBucketReplicationArgs args)
Gets bucket replication configuration of a bucket.
|
Tags |
getBucketTags(GetBucketTagsArgs args)
Gets tags of a bucket.
|
VersioningConfiguration |
getBucketVersioning(GetBucketVersioningArgs args)
Gets versioning configuration of a bucket.
|
GetObjectResponse |
getObject(GetObjectArgs args)
Gets data from offset to length of a SSE-C encrypted object.
|
ObjectLockConfiguration |
getObjectLockConfiguration(GetObjectLockConfigurationArgs args)
Gets default object retention in a bucket.
|
Retention |
getObjectRetention(GetObjectRetentionArgs args)
Gets retention configuration of an object.
|
Tags |
getObjectTags(GetObjectTagsArgs args)
Gets tags of an object.
|
String |
getPresignedObjectUrl(GetPresignedObjectUrlArgs args)
Gets presigned URL of an object for HTTP method, expiry time and custom request parameters.
|
Map<String,String> |
getPresignedPostFormData(PostPolicy policy)
Gets form-data of
PostPolicy of an object to upload its data using POST method. |
protected String |
getRegion(String bucketName,
String region)
Returns region of given bucket either from region cache or set in constructor.
|
void |
ignoreCertCheck()
Ignores check on server certificate for HTTPS connection.
|
boolean |
isObjectLegalHoldEnabled(IsObjectLegalHoldEnabledArgs args)
Returns true if legal hold is enabled on an object.
|
List<Bucket> |
listBuckets()
Lists bucket information of all buckets.
|
List<Bucket> |
listBuckets(ListBucketsArgs args)
Lists bucket information of all buckets.
|
CloseableIterator<Result<NotificationRecords>> |
listenBucketNotification(ListenBucketNotificationArgs args)
Listens events of object prefix and suffix of a bucket.
|
protected ListMultipartUploadsResponse |
listMultipartUploads(String bucketName,
String region,
String delimiter,
String encodingType,
String keyMarker,
Integer maxUploads,
String prefix,
String uploadIdMarker,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
Iterable<Result<Item>> |
listObjects(ListObjectsArgs args)
Lists objects information optionally with versions of a bucket.
|
protected ListObjectsV1Response |
listObjectsV1(String bucketName,
String region,
String delimiter,
String encodingType,
String marker,
Integer maxKeys,
String prefix,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
protected ListObjectsV2Response |
listObjectsV2(String bucketName,
String region,
String delimiter,
String encodingType,
String startAfter,
Integer maxKeys,
String prefix,
String continuationToken,
boolean fetchOwner,
boolean includeUserMetadata,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
protected ListObjectVersionsResponse |
listObjectVersions(String bucketName,
String region,
String delimiter,
String encodingType,
String keyMarker,
Integer maxKeys,
String prefix,
String versionIdMarker,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
protected ListPartsResponse |
listParts(String bucketName,
String region,
String objectName,
Integer maxParts,
Integer partNumberMarker,
String uploadId,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
Do ListParts S3
API.
|
void |
makeBucket(MakeBucketArgs args)
Creates a bucket with region and object lock.
|
ObjectWriteResponse |
putObject(PutObjectArgs args)
Uploads data from a stream to an object.
|
protected ObjectWriteResponse |
putObject(String bucketName,
String region,
String objectName,
Object data,
int length,
com.google.common.collect.Multimap<String,String> headers,
com.google.common.collect.Multimap<String,String> extraQueryParams)
Do PutObject S3
API.
|
void |
removeBucket(RemoveBucketArgs args)
Removes an empty bucket using arguments
|
void |
removeObject(RemoveObjectArgs args)
Removes an object.
|
Iterable<Result<DeleteError>> |
removeObjects(RemoveObjectsArgs args)
Removes multiple objects lazily.
|
SelectResponseStream |
selectObjectContent(SelectObjectContentArgs args)
Selects content of an object by SQL expression.
|
void |
setAppInfo(String name,
String version)
Sets application's name/version to user agent.
|
void |
setBucketEncryption(SetBucketEncryptionArgs args)
Sets encryption configuration of a bucket.
|
void |
setBucketLifecycle(SetBucketLifecycleArgs args)
Sets lifecycle configuration to a bucket.
|
void |
setBucketNotification(SetBucketNotificationArgs args)
Sets notification configuration to a bucket.
|
void |
setBucketPolicy(SetBucketPolicyArgs args)
Sets bucket policy configuration to a bucket.
|
void |
setBucketReplication(SetBucketReplicationArgs args)
Sets bucket replication configuration to a bucket.
|
void |
setBucketTags(SetBucketTagsArgs args)
Sets tags to a bucket.
|
void |
setBucketVersioning(SetBucketVersioningArgs args)
Sets versioning configuration of a bucket.
|
void |
setObjectLockConfiguration(SetObjectLockConfigurationArgs args)
Sets default object retention in a bucket.
|
void |
setObjectRetention(SetObjectRetentionArgs args)
Sets retention configuration to an object.
|
void |
setObjectTags(SetObjectTagsArgs args)
Sets tags to an object.
|
void |
setTimeout(long connectTimeout,
long writeTimeout,
long readTimeout)
Sets HTTP connect, write and read timeouts.
|
StatObjectResponse |
statObject(StatObjectArgs args)
Gets information of an object.
|
void |
traceOff()
Disables HTTP call tracing previously enabled.
|
void |
traceOn(OutputStream traceStream)
Enables HTTP call tracing and written to traceStream.
|
ObjectWriteResponse |
uploadObject(UploadObjectArgs args)
Uploads data from a file to an object.
|
protected UploadPartResponse |
uploadPart(String bucketName,
String region,
String objectName,
Object data,
int length,
String uploadId,
int partNumber,
com.google.common.collect.Multimap<String,String> extraHeaders,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
protected UploadPartCopyResponse |
uploadPartCopy(String bucketName,
String region,
String objectName,
String uploadId,
int partNumber,
com.google.common.collect.Multimap<String,String> headers,
com.google.common.collect.Multimap<String,String> extraQueryParams)
|
protected MinioClient(MinioClient client)
protected okhttp3.HttpUrl buildUrl(Method method, String bucketName, String objectName, String region, com.google.common.collect.Multimap<String,String> queryParamMap) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionprotected okhttp3.Request createRequest(okhttp3.HttpUrl url,
Method method,
okhttp3.Headers headers,
Object body,
int length,
Credentials creds)
throws InsufficientDataException,
InternalException,
IOException,
NoSuchAlgorithmException
protected okhttp3.Response execute(Method method, BaseArgs args, com.google.common.collect.Multimap<String,String> headers, com.google.common.collect.Multimap<String,String> queryParams, Object body, int length) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
protected okhttp3.Response execute(Method method, String bucketName, String objectName, String region, okhttp3.Headers headers, com.google.common.collect.Multimap<String,String> queryParamMap, Object body, int length) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
protected String getRegion(String bucketName, String region) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
public StatObjectResponse statObject(StatObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - StatObjectArgs object.StatObjectResponse - Populated object information and metadata.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.ServerExceptionStatObjectResponsepublic GetObjectResponse getObject(GetObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
InputStream must
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
}
args - Object of GetObjectArgsErrorResponseException - 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.ServerExceptionpublic void downloadObject(DownloadObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.downloadObject(
GetObjectArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.ssec(ssec)
.fileName("my-filename")
.build());
args - Object of DownloadObjectArgsErrorResponseException - 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.ServerExceptionpublic ObjectWriteResponse copyObject(CopyObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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")
.srcBucket("my-source-bucketname")
.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")
.srcBucket("my-source-bucketname")
.srcObject("my-source-objectname")
.build());
// Create object "my-objectname" in bucket "my-bucketname" with server-side encryption by
// copying from object "my-objectname" in bucket "my-source-bucketname".
minioClient.copyObject(
CopyObjectArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.srcBucket("my-source-bucketname")
.sse(sse)
.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")
.srcBucket("my-source-bucketname")
.srcObject("my-source-objectname")
.srcSsec(ssec)
.build());
// Create object "my-objectname" in bucket "my-bucketname" with custom headers by copying from
// object "my-objectname" in bucket "my-source-bucketname" using conditions.
minioClient.copyObject(
CopyObjectArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.srcBucket("my-source-bucketname")
.headers(headers)
.srcMatchETag(etag)
.build());
args - CopyObjectArgs object.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.ServerExceptionpublic ObjectWriteResponse composeObject(ComposeObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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.
minioClient.composeObject(
ComposeObjectArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.sources(sourceObjectList)
.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)
.ssec(sse)
.build());
args - ComposeObjectArgs object.ObjectWriteResponse object.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.ServerExceptionpublic String getPresignedObjectUrl(GetPresignedObjectUrlArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException, ServerException
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);
args - GetPresignedObjectUrlArgs object.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.ServerExceptionpublic Map<String,String> getPresignedPostFormData(PostPolicy policy) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
PostPolicy of 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");
}
policy - Post policy of an object.Map<String, String> - Contains form-data to upload an object using POST method.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.ServerExceptionPostPolicypublic void removeObject(RemoveObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - RemoveObjectArgs object.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.ServerExceptionpublic Iterable<Result<DeleteError>> removeObjects(RemoveObjectsArgs args)
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());
}
args - RemoveObjectsArgs object.Iterable<Result<DeleteError>> - Lazy iterator contains object removal status.public Iterable<Result<Item>> listObjects(ListObjectsArgs args)
useVersion1 as true.
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());
args - Instance of ListObjectsArgs built using the builderIterable<Result<Item>> - Lazy iterator contains object information.XmlParserException - upon parsing response xmlpublic List<Bucket> listBuckets() throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
List<Bucket> bucketList = minioClient.listBuckets();
for (Bucket bucket : bucketList) {
System.out.println(bucket.creationDate() + ", " + bucket.name());
}
List<Bucket> - List of bucket information.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.ServerExceptionpublic List<Bucket> listBuckets(ListBucketsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
List<Bucket> bucketList =
minioClient.listBuckets(ListBucketsArgs.builder().extraHeaders(headers).build());
for (Bucket bucket : bucketList) {
System.out.println(bucket.creationDate() + ", " + bucket.name());
}
List<Bucket> - List of bucket information.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.ServerExceptionpublic boolean bucketExists(BucketExistsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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");
}
args - BucketExistsArgs object.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.ServerExceptionpublic void makeBucket(MakeBucketArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - Object with bucket name, region and lock functionalityErrorResponseException - 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.ServerExceptionpublic void setBucketVersioning(SetBucketVersioningArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.setBucketVersioning(
SetBucketVersioningArgs.builder().bucket("my-bucketname").config(config).build());
args - SetBucketVersioningArgs object.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.ServerExceptionpublic VersioningConfiguration getBucketVersioning(GetBucketVersioningArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
VersioningConfiguration config =
minioClient.getBucketVersioning(
GetBucketVersioningArgs.builder().bucket("my-bucketname").build());
args - GetBucketVersioningArgs object.VersioningConfiguration - Versioning configuration.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.ServerExceptionpublic void setObjectLockConfiguration(SetObjectLockConfigurationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
ObjectLockConfiguration config = new ObjectLockConfiguration(
RetentionMode.COMPLIANCE, new RetentionDurationDays(100));
minioClient.setObjectLockConfiguration(
SetObjectLockConfigurationArgs.builder().bucket("my-bucketname").config(config).build());
args - SetObjectLockConfigurationArgs object.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.ServerExceptionpublic void deleteObjectLockConfiguration(DeleteObjectLockConfigurationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteObjectLockConfiguration(
DeleteObjectLockConfigurationArgs.builder().bucket("my-bucketname").build());
args - DeleteObjectLockConfigurationArgs object.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.ServerExceptionpublic ObjectLockConfiguration getObjectLockConfiguration(GetObjectLockConfigurationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - GetObjectLockConfigurationArgs object.ObjectLockConfiguration - Default retention configuration.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.ServerExceptionpublic void setObjectRetention(SetObjectRetentionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetObjectRetentionArgs object.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.ServerExceptionpublic Retention getObjectRetention(GetObjectRetentionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
Retention retention =
minioClient.getObjectRetention(GetObjectRetentionArgs.builder()
.bucket(bucketName)
.object(objectName)
.versionId(versionId)
.build()););
System.out.println(
"mode: " + retention.mode() + "until: " + retention.retainUntilDate());
args - GetObjectRetentionArgs object.Retention - Object retention configuration.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.ServerExceptionpublic void enableObjectLegalHold(EnableObjectLegalHoldArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.enableObjectLegalHold(
EnableObjectLegalHoldArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.versionId("object-versionId")
.build());
args - EnableObjectLegalHoldArgs object.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.ServerExceptionpublic void disableObjectLegalHold(DisableObjectLegalHoldArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.disableObjectLegalHold(
DisableObjectLegalHoldArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.versionId("object-versionId")
.build());
args - DisableObjectLegalHoldArgs object.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.ServerExceptionpublic boolean isObjectLegalHoldEnabled(IsObjectLegalHoldEnabledArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
boolean 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");
}
args IsObjectLegalHoldEnabledArgs object.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.ServerExceptionpublic void removeBucket(RemoveBucketArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.removeBucket(RemoveBucketArgs.builder().bucket("my-bucketname").build());
args - RemoveBucketArgs bucket.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.ServerExceptionpublic ObjectWriteResponse putObject(PutObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - PutObjectArgs object.ObjectWriteResponse object.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.ServerExceptionpublic ObjectWriteResponse uploadObject(UploadObjectArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - UploadObjectArgs object.ObjectWriteResponse object.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.ServerExceptionpublic String getBucketPolicy(GetBucketPolicyArgs args) throws BucketPolicyTooLargeException, ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
String config =
minioClient.getBucketPolicy(GetBucketPolicyArgs.builder().bucket("my-bucketname").build());
args - GetBucketPolicyArgs object.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.ServerExceptionpublic void setBucketPolicy(SetBucketPolicyArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetBucketPolicyArgs object.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.ServerExceptionpublic void deleteBucketPolicy(DeleteBucketPolicyArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteBucketPolicy(DeleteBucketPolicyArgs.builder().bucket("my-bucketname"));
args - DeleteBucketPolicyArgs object.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.ServerExceptionpublic void setBucketLifecycle(SetBucketLifecycleArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetBucketLifecycleArgs object.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.ServerExceptionpublic void deleteBucketLifecycle(DeleteBucketLifecycleArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
deleteBucketLifecycle(DeleteBucketLifecycleArgs.builder().bucket("my-bucketname").build());
args - DeleteBucketLifecycleArgs object.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.ServerExceptionpublic LifecycleConfiguration getBucketLifecycle(GetBucketLifecycleArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
LifecycleConfiguration config =
minioClient.getBucketLifecycle(
GetBucketLifecycleArgs.builder().bucket("my-bucketname").build());
args - GetBucketLifecycleArgs object.LifecycleConfiguration object.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.ServerExceptionpublic NotificationConfiguration getBucketNotification(GetBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
NotificationConfiguration config =
minioClient.getBucketNotification(
GetBucketNotificationArgs.builder().bucket("my-bucketname").build());
args - GetBucketNotificationArgs object.NotificationConfiguration - Notification configuration.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.ServerExceptionpublic void setBucketNotification(SetBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetBucketNotificationArgs object.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.ServerExceptionpublic void deleteBucketNotification(DeleteBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteBucketNotification(
DeleteBucketNotificationArgs.builder().bucket("my-bucketname").build());
args - DeleteBucketNotificationArgs object.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.ServerExceptionpublic ReplicationConfiguration getBucketReplication(GetBucketReplicationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
ReplicationConfiguration config =
minioClient.getBucketReplication(
GetBucketReplicationArgs.builder().bucket("my-bucketname").build());
args - GetBucketReplicationArgs object.ReplicationConfiguration object.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.ServerExceptionpublic void setBucketReplication(SetBucketReplicationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetBucketReplicationArgs object.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.ServerExceptionpublic void deleteBucketReplication(DeleteBucketReplicationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteBucketReplication(
DeleteBucketReplicationArgs.builder().bucket("my-bucketname"));
args - DeleteBucketReplicationArgs object.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.ServerExceptionpublic CloseableIterator<Result<NotificationRecords>> listenBucketNotification(ListenBucketNotificationArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
}
}
}
args - ListenBucketNotificationArgs object.CloseableIterator<Result<NotificationRecords>> - Lazy closable iterator
contains event records.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.ServerExceptionpublic SelectResponseStream selectObjectContent(SelectObjectContentArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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();
args - instance of SelectObjectContentArgsSelectResponseStream - Contains filtered records and progress.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.ServerExceptionpublic void setBucketEncryption(SetBucketEncryptionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.setBucketEncryption(
SetBucketEncryptionArgs.builder().bucket("my-bucketname").config(config).build());
args - SetBucketEncryptionArgs object.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.ServerExceptionpublic SseConfiguration getBucketEncryption(GetBucketEncryptionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
SseConfiguration config =
minioClient.getBucketEncryption(
GetBucketEncryptionArgs.builder().bucket("my-bucketname").build());
args - GetBucketEncryptionArgs object.SseConfiguration - Server-side encryption configuration.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.ServerExceptionpublic void deleteBucketEncryption(DeleteBucketEncryptionArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteBucketEncryption(
DeleteBucketEncryptionArgs.builder().bucket("my-bucketname").build());
args - DeleteBucketEncryptionArgs object.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.ServerExceptionpublic Tags getBucketTags(GetBucketTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
Tags tags =
minioClient.getBucketTags(GetBucketTagsArgs.builder().bucket("my-bucketname").build());
args - GetBucketTagsArgs object.Tags - Tags.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.ServerExceptionpublic void setBucketTags(SetBucketTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetBucketTagsArgs object.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.ServerExceptionpublic void deleteBucketTags(DeleteBucketTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteBucketTags(DeleteBucketTagsArgs.builder().bucket("my-bucketname").build());
args - DeleteBucketTagsArgs object.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.ServerExceptionpublic Tags getObjectTags(GetObjectTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
Tags tags =
minioClient.getObjectTags(
GetObjectTagsArgs.builder().bucket("my-bucketname").object("my-objectname").build());
args - GetObjectTagsArgs object.Tags - Tags.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.ServerExceptionpublic void setObjectTags(SetObjectTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
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());
args - SetObjectTagsArgs object.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.ServerExceptionpublic void deleteObjectTags(DeleteObjectTagsArgs args) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException
Example:
minioClient.deleteObjectTags(
DeleteObjectTags.builder().bucket("my-bucketname").object("my-objectname").build());
args - DeleteObjectTagsArgs object.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.ServerExceptionpublic void setTimeout(long connectTimeout,
long writeTimeout,
long readTimeout)
Example:
minioClient.setTimeout(TimeUnit.SECONDS.toMillis(10), TimeUnit.SECONDS.toMillis(10),
TimeUnit.SECONDS.toMillis(30));
connectTimeout - HTTP connect timeout in milliseconds.writeTimeout - HTTP write timeout in milliseconds.readTimeout - HTTP read timeout in milliseconds.public void ignoreCertCheck()
throws KeyManagementException,
NoSuchAlgorithmException
Example:
minioClient.ignoreCertCheck();
KeyManagementException - thrown to indicate key management error.NoSuchAlgorithmException - thrown to indicate missing of SSL library.public void setAppInfo(String name, String version)
name - Your application name.version - Your application version.public void traceOn(OutputStream traceStream)
traceStream - OutputStream for writing HTTP call tracing.traceOff()public void traceOff()
throws IOException
IOException - upon connection errortraceOn(java.io.OutputStream)public void enableAccelerateEndpoint()
public void disableAccelerateEndpoint()
public void enableDualStackEndpoint()
public void disableDualStackEndpoint()
public void enableVirtualStyleEndpoint()
public void disableVirtualStyleEndpoint()
protected AbortMultipartUploadResponse abortMultipartUpload(String bucketName, String region, String objectName, String uploadId, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket.objectName - Object name in the bucket.uploadId - Upload ID.extraHeaders - Extra headers (Optional).extraQueryParams - Extra query parameters (Optional).AbortMultipartUploadResponse object.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.ServerExceptionprotected ObjectWriteResponse completeMultipartUpload(String bucketName, String region, String objectName, String uploadId, Part[] parts, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket.objectName - Object name in the bucket.uploadId - Upload ID.parts - List of parts.extraHeaders - Extra headers (Optional).extraQueryParams - Extra query parameters (Optional).ObjectWriteResponse object.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.ServerExceptionprotected CreateMultipartUploadResponse createMultipartUpload(String bucketName, String region, String objectName, com.google.common.collect.Multimap<String,String> headers, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region name of buckets in S3 service.objectName - Object name in the bucket.headers - Request headers.extraQueryParams - Extra query parameters for request (Optional).CreateMultipartUploadResponse object.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.ServerExceptionprotected DeleteObjectsResponse deleteObjects(String bucketName, String region, List<DeleteObject> objectList, boolean quiet, boolean bypassGovernanceMode, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket (Optional).objectList - List of object names.quiet - Quiet flag.bypassGovernanceMode - Bypass Governance retention mode.extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).DeleteObjectsResponse object.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.ServerExceptionprotected ListObjectsV2Response listObjectsV2(String bucketName, String region, String delimiter, String encodingType, String startAfter, Integer maxKeys, String prefix, String continuationToken, boolean fetchOwner, boolean includeUserMetadata, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException, IOException
bucketName - Name of the bucket.region - Region of the bucket (Optional).delimiter - Delimiter (Optional).encodingType - Encoding type (Optional).startAfter - Fetch listing after this key (Optional).maxKeys - Maximum object information to fetch (Optional).prefix - Prefix (Optional).continuationToken - Continuation token (Optional).fetchOwner - Flag to fetch owner information (Optional).includeUserMetadata - MinIO extension flag to include user metadata (Optional).extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).ListObjectsV2Response object.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.ServerExceptionprotected ListObjectsV1Response listObjectsV1(String bucketName, String region, String delimiter, String encodingType, String marker, Integer maxKeys, String prefix, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket (Optional).delimiter - Delimiter (Optional).encodingType - Encoding type (Optional).marker - Marker (Optional).maxKeys - Maximum object information to fetch (Optional).prefix - Prefix (Optional).extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).ListObjectsV1Response object.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.ServerExceptionprotected ListObjectVersionsResponse listObjectVersions(String bucketName, String region, String delimiter, String encodingType, String keyMarker, Integer maxKeys, String prefix, String versionIdMarker, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket (Optional).delimiter - Delimiter (Optional).encodingType - Encoding type (Optional).keyMarker - Key marker (Optional).maxKeys - Maximum object information to fetch (Optional).prefix - Prefix (Optional).versionIdMarker - Version ID marker (Optional).extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).ListObjectVersionsResponse object.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.ServerExceptionprotected ObjectWriteResponse putObject(String bucketName, String region, String objectName, Object data, int length, com.google.common.collect.Multimap<String,String> headers, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.objectName - Object name in the bucket.data - Object data must be BufferedInputStream, RandomAccessFile, byte[] or String.length - Length of object data.headers - Additional headers.extraQueryParams - Additional query parameters if any.ObjectWriteResponse object.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.ServerExceptionprotected ListMultipartUploadsResponse listMultipartUploads(String bucketName, String region, String delimiter, String encodingType, String keyMarker, Integer maxUploads, String prefix, String uploadIdMarker, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket (Optional).delimiter - Delimiter (Optional).encodingType - Encoding type (Optional).keyMarker - Key marker (Optional).maxUploads - Maximum upload information to fetch (Optional).prefix - Prefix (Optional).uploadIdMarker - Upload ID marker (Optional).extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).ListMultipartUploadsResponse object.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.ServerExceptionprotected ListPartsResponse listParts(String bucketName, String region, String objectName, Integer maxParts, Integer partNumberMarker, String uploadId, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Name of the bucket (Optional).objectName - Object name in the bucket.maxParts - Maximum parts information to fetch (Optional).partNumberMarker - Part number marker (Optional).uploadId - Upload ID.extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).ListPartsResponse object.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.ServerExceptionprotected UploadPartResponse uploadPart(String bucketName, String region, String objectName, Object data, int length, String uploadId, int partNumber, com.google.common.collect.Multimap<String,String> extraHeaders, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket (Optional).objectName - Object name in the bucket.data - Object data must be BufferedInputStream, RandomAccessFile, byte[] or String.length - Length of object data.uploadId - Upload ID.partNumber - Part number.extraHeaders - Extra headers for request (Optional).extraQueryParams - Extra query parameters for request (Optional).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.ServerExceptionprotected UploadPartCopyResponse uploadPartCopy(String bucketName, String region, String objectName, String uploadId, int partNumber, com.google.common.collect.Multimap<String,String> headers, com.google.common.collect.Multimap<String,String> extraQueryParams) throws NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, ServerException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
bucketName - Name of the bucket.region - Region of the bucket (Optional).objectName - Object name in the bucket.uploadId - Upload ID.partNumber - Part number.headers - Request headers with source object definitions.extraQueryParams - Extra query parameters for request (Optional).UploadPartCopyResponse object.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.ServerExceptionpublic static MinioClient.Builder builder()