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.
| Constructor and Description |
|---|
MinioClient(okhttp3.HttpUrl url)
Creates MinIO client object with given HttpUrl object using anonymous access.
|
MinioClient(okhttp3.HttpUrl url,
String accessKey,
String secretKey)
Creates MinIO client object with given URL object, access key and secret key.
|
MinioClient(String endpoint)
Creates MinIO client object with given endpoint using anonymous access.
|
MinioClient(String endpoint,
int port,
String accessKey,
String secretKey)
Creates MinIO client object with given endpoint, port, access key and secret key.
|
MinioClient(String endpoint,
int port,
String accessKey,
String secretKey,
boolean secure)
Creates MinIO client object using given endpoint, port, access key, secret key and secure (TLS)
connection.
|
MinioClient(String endpoint,
int port,
String accessKey,
String secretKey,
String region,
boolean secure)
Creates MinIO client object using given endpoint, port, access key, secret key, region and
secure (TLS) connection.
|
MinioClient(String endpoint,
int port,
String accessKey,
String secretKey,
String region,
boolean secure,
okhttp3.OkHttpClient httpClient)
Creates MinIO client object using given endpoint, port, access key, secret key, region and
secure (TLS) connection.
|
MinioClient(String endpoint,
String accessKey,
String secretKey)
Creates MinIO client object with given endpoint, access key and secret key.
|
MinioClient(String endpoint,
String accessKey,
String secretKey,
boolean secure)
Creates MinIO client object with given endpoint, access key and secret key using secure (TLS)
connection.
|
MinioClient(String endpoint,
String accessKey,
String secretKey,
String region)
Creates MinIO client object with given endpoint, access key, secret key and region name.
|
MinioClient(URL url)
Creates MinIO client object with given URL object using anonymous access.
|
MinioClient(URL url,
String accessKey,
String secretKey)
Creates MinIO client object with given URL object, access key and secret key.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
bucketExists(String bucketName)
Checks if given bucket exist and is having read access.
|
void |
composeObject(String bucketName,
String objectName,
List<ComposeSource> sources,
Map<String,String> headerMap,
ServerSideEncryption sse)
Create an object by concatenating a list of source objects using server-side copying.
|
void |
copyObject(String bucketName,
String objectName,
Map<String,String> headerMap,
ServerSideEncryption sse,
String srcBucketName,
String srcObjectName,
ServerSideEncryption srcSse,
CopyConditions copyConditions)
Copy a source object into a new object with the provided name in the provided bucket.
|
void |
deleteBucketLifeCycle(String bucketName)
Delete the LifeCycle of bucket.
|
void |
disableObjectLegalHold(String bucketName,
String objectName,
String versionId)
Disable object legal hold on an object.
|
void |
disableVersioning(String bucketName)
Disable object versioning in given bucket.
|
void |
enableObjectLegalHold(String bucketName,
String objectName,
String versionId)
Enables object legal hold on an object.
|
void |
enableVersioning(String bucketName)
Enable object versioning in given bucket.
|
String |
getBucketLifeCycle(String bucketName)
Get bucket life cycle configuration.
|
NotificationConfiguration |
getBucketNotification(String bucketName)
Get bucket notification configuration
|
String |
getBucketPolicy(String bucketName)
Get JSON string of bucket policy of the given bucket.
|
ObjectLockConfiguration |
getDefaultRetention(String bucketName)
Gets default object retention in given bucket.
|
InputStream |
getObject(String bucketName,
String objectName)
Gets entire object's data as
InputStream in given bucket. |
InputStream |
getObject(String bucketName,
String objectName,
long offset)
Gets object's data starting from given offset as
InputStream in the given bucket. |
InputStream |
getObject(String bucketName,
String objectName,
long offset,
Long length)
Gets object's data of given offset and length as
InputStream in the given bucket. |
InputStream |
getObject(String bucketName,
String objectName,
Long offset,
Long length,
ServerSideEncryption sse)
Gets object's data of given offset and length as
InputStream in the given bucket. |
InputStream |
getObject(String bucketName,
String objectName,
ServerSideEncryption sse)
Gets entire object's data as
InputStream in given bucket. |
void |
getObject(String bucketName,
String objectName,
ServerSideEncryption sse,
String fileName)
Gets encrypted object's data in the given bucket and stores it to given file name.
|
void |
getObject(String bucketName,
String objectName,
String fileName)
Gets object's data in the given bucket and stores it to given file name.
|
Retention |
getObjectRetention(String bucketName,
String objectName,
String versionId)
Fetches object retention lock of an object.
|
String |
getObjectUrl(String bucketName,
String objectName)
Gets object's URL in given bucket.
|
String |
getPresignedObjectUrl(Method method,
String bucketName,
String objectName,
Integer expires,
Map<String,String> reqParams)
Returns a presigned URL string with given HTTP method, expiry time and custom request params
for a specific object in the bucket.
|
void |
ignoreCertCheck()
Ignores check on server certificate for HTTPS connection.
|
boolean |
isObjectLegalHoldEnabled(String bucketName,
String objectName,
String versionId)
Returns true if the object legal hold is enabled.
|
List<Bucket> |
listBuckets()
Returns all bucket information owned by the current user.
|
CloseableIterator<Result<NotificationRecords>> |
listenBucketNotification(String bucketName,
String prefix,
String suffix,
String[] events)
Listen to bucket notifications.
|
Iterable<Result<Upload>> |
listIncompleteUploads(String bucketName)
Lists incomplete uploads of objects in given bucket.
|
Iterable<Result<Upload>> |
listIncompleteUploads(String bucketName,
String prefix)
Lists incomplete uploads of objects in given bucket and prefix.
|
Iterable<Result<Upload>> |
listIncompleteUploads(String bucketName,
String prefix,
boolean recursive)
Lists incomplete uploads of objects in given bucket, prefix and recursive flag.
|
Iterable<Result<Item>> |
listObjects(String bucketName)
Lists object information in given bucket.
|
Iterable<Result<Item>> |
listObjects(String bucketName,
String prefix)
Lists object information in given bucket and prefix.
|
Iterable<Result<Item>> |
listObjects(String bucketName,
String prefix,
boolean recursive)
Lists object information as
Iterable<Result><Item> in given bucket, prefix and
recursive flag. |
Iterable<Result<Item>> |
listObjects(String bucketName,
String prefix,
boolean recursive,
boolean useVersion1)
Lists object information as
Iterable<Result><Item> in given bucket, prefix, recursive
flag and S3 API version to use. |
Iterable<Result<Item>> |
listObjects(String bucketName,
String prefix,
boolean recursive,
boolean includeUserMetadata,
boolean useVersion1)
Lists object information as
Iterable<Result><Item> in given bucket, prefix, recursive
flag, user metadata flag and S3 API version to use. |
void |
makeBucket(String bucketName)
Creates a bucket with default region.
|
void |
makeBucket(String bucketName,
String region)
Creates a bucket with given region.
|
void |
makeBucket(String bucketName,
String region,
boolean objectLock)
Creates a bucket with given region and object lock option.
|
String |
presignedGetObject(String bucketName,
String objectName)
Returns an presigned URL to download the object in the bucket with default expiry time.
|
String |
presignedGetObject(String bucketName,
String objectName,
Integer expires)
Returns an presigned URL to download the object in the bucket with given expiry time.
|
String |
presignedGetObject(String bucketName,
String objectName,
Integer expires,
Map<String,String> reqParams)
Returns an presigned URL to download the object in the bucket with given expiry time with
custom request params.
|
Map<String,String> |
presignedPostPolicy(PostPolicy policy)
Returns string map for given
PostPolicy to upload object with various post policy
conditions. |
String |
presignedPutObject(String bucketName,
String objectName)
Returns a presigned URL to upload an object in the bucket with default expiry time.
|
String |
presignedPutObject(String bucketName,
String objectName,
Integer expires)
Returns a presigned URL to upload an object in the bucket with given expiry time.
|
void |
putObject(String bucketName,
String objectName,
InputStream stream,
PutObjectOptions options)
Uploads data from given stream as object to given bucket using given PutObjectOptions.
|
void |
putObject(String bucketName,
String objectName,
String filename,
PutObjectOptions options)
Uploads data from given file as object to given bucket using given PutObjectOptions.
|
void |
removeAllBucketNotification(String bucketName)
Remove all bucket notification.
|
void |
removeBucket(String bucketName)
Removes an empty bucket.
|
void |
removeIncompleteUpload(String bucketName,
String objectName)
Removes incomplete multipart upload of given object.
|
void |
removeObject(String bucketName,
String objectName)
Removes an object from a bucket.
|
Iterable<Result<DeleteError>> |
removeObjects(String bucketName,
Iterable<String> objectNames)
Removes multiple objects from a bucket.
|
SelectResponseStream |
selectObjectContent(String bucketName,
String objectName,
String sqlExpression,
InputSerialization is,
OutputSerialization os,
boolean requestProgress,
Long scanStartRange,
Long scanEndRange,
ServerSideEncryption sse)
Select object content using SQL expression.
|
void |
setAppInfo(String name,
String version)
Sets application's name/version to user agent.
|
void |
setBucketLifeCycle(String bucketName,
String lifeCycle)
Set XML string of LifeCycle on a given bucket.
|
void |
setBucketNotification(String bucketName,
NotificationConfiguration notificationConfiguration)
Set bucket notification configuration
|
void |
setBucketPolicy(String bucketName,
String policy)
Set JSON string of policy on given bucket.
|
void |
setDefaultRetention(String bucketName,
ObjectLockConfiguration config)
Sets default object retention in given bucket.
|
void |
setObjectRetention(String bucketName,
String objectName,
String versionId,
Retention config,
boolean bypassGovernanceRetention)
Applies object retention lock onto an object.
|
void |
setTimeout(long connectTimeout,
long writeTimeout,
long readTimeout)
Sets HTTP connect, write and read timeouts.
|
ObjectStat |
statObject(String bucketName,
String objectName)
Returns meta data information of given object in given bucket.
|
ObjectStat |
statObject(String bucketName,
String objectName,
ServerSideEncryption sse)
Returns meta data information of given object in given bucket.
|
void |
traceOff()
Disables HTTP call tracing previously enabled.
|
void |
traceOn(OutputStream traceStream)
Enables HTTP call tracing and written to traceStream.
|
public MinioClient(String endpoint) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("https://play.min.io");endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1InvalidEndpointExceptionInvalidPortExceptionMinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(URL url) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient(new URL("https://play.min.io"));url - Endpoint as URL object.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(okhttp3.HttpUrl url)
throws InvalidEndpointException,
InvalidPortException
Example:
MinioClient minioClient = new MinioClient(new HttpUrl.parse("https://play.min.io"));
url - Endpoint as HttpUrl object.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("https://play.min.io",
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, String accessKey, String secretKey, String region) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("https://play.min.io",
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", "us-west-1");endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.region - Region name of buckets in S3 service.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(URL url, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient(new URL("https://play.min.io"),
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");url - Endpoint as URL object.accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(okhttp3.HttpUrl url,
String accessKey,
String secretKey)
throws InvalidEndpointException,
InvalidPortException
Example:
MinioClient minioClient = new MinioClient(HttpUrl.parse("https://play.min.io"),
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");url - Endpoint as HttpUrl object.accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, int port, String accessKey, String secretKey) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("play.min.io", 9000,
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1port - TCP/IP port number between 1 and 65535. Unused if endpoint is an URL.accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, String accessKey, String secretKey, boolean secure) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("play.min.io",
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true);endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.secure - Flag to indicate to use secure (TLS) connection to S3 service or not.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean
secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("play.min.io", 9000,
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true);endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1port - TCP/IP port number between 1 and 65535. Unused if endpoint is an URL.accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.secure - Flag to indicate to use secure (TLS) connection to S3 service or not.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, int port, String accessKey, String secretKey, String region, boolean secure) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("play.min.io", 9000,
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true);endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1port - TCP/IP port number between 1 and 65535. Unused if endpoint is an URL.accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.region - Region name of buckets in S3 service.secure - Flag to indicate to use secure (TLS) connection to S3 service or not.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure, OkHttpClient httpClient)public MinioClient(String endpoint, int port, String accessKey, String secretKey, String region, boolean secure, okhttp3.OkHttpClient httpClient) throws InvalidEndpointException, InvalidPortException
Example:
MinioClient minioClient = new MinioClient("play.min.io", 9000,
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true,
customHttpClient);endpoint - Endpoint is an URL, domain name, IPv4 or IPv6 address of S3 service.
Examples:
* https://s3.amazonaws.com
* https://s3.amazonaws.com/
* https://play.min.io
* http://play.min.io:9010/
* localhost
* localhost.localdomain
* play.min.io
* 127.0.0.1
* 192.168.1.60
* ::1port - TCP/IP port number between 1 and 65535. Unused if endpoint is an URL.accessKey - Access key (aka user ID) of your account in S3 service.secretKey - Secret Key (aka password) of your account in S3 service.region - Region name of buckets in S3 service.secure - Flag to indicate to use secure (TLS) connection to S3 service or not.httpClient - Customized HTTP client object.InvalidEndpointExceptionInvalidPortExceptionMinioClient(String endpoint),
MinioClient(URL url),
MinioClient(String endpoint, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, String region),
MinioClient(URL url, String accessKey, String secretKey),
MinioClient(String endpoint, int port, String accessKey, String secretKey),
MinioClient(String endpoint, String accessKey, String secretKey, boolean secure),
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region,
boolean secure)public ObjectStat statObject(String bucketName, String objectName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException, IllegalArgumentException
Example:
ObjectStat objectStat = minioClient.statObject("my-bucketname", "my-objectname");
bucketName - Bucket name.objectName - Object name in the bucket.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionObjectStatpublic ObjectStat statObject(String bucketName, String objectName, ServerSideEncryption sse) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
Example:
ObjectStat objectStat = minioClient.statObject("my-bucketname", "my-objectname", sse);
bucketName - Bucket name.objectName - Object name in the bucket.sse - SSE-C type of server-side encryption.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverObjectStatpublic String getObjectUrl(String bucketName, String objectName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
String url = minioClient.getObjectUrl("my-bucketname", "my-objectname");bucketName - Bucket name.objectName - Object name in the bucket.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic InputStream getObject(String bucketName, String objectName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
InputStream in given bucket. The InputStream must be
closed after use else the connection will remain open.
Example:
InputStream stream = minioClient.getObject("my-bucketname", "my-objectname");
bucketName - Bucket name.objectName - Object name in the bucket.InputStream containing the object data.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic InputStream getObject(String bucketName, String objectName, ServerSideEncryption sse) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
InputStream in given bucket. The InputStream must be
closed after use else the connection will remain open.
Example:
InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", sse);
bucketName - Bucket name.objectName - Object name in the bucket.sse - Encryption metadata only required for SSE-C.InputStream containing the object data.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic InputStream getObject(String bucketName, String objectName, long offset) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
InputStream in the given bucket. The
InputStream must be closed after use else the connection will remain open.
Example:
InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", 1024L);
bucketName - Bucket name.objectName - Object name in the bucket.offset - Offset to read at.InputStream containing the object's data.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic InputStream getObject(String bucketName, String objectName, long offset, Long length) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
InputStream in the given bucket. The
InputStream must be closed after use else the connection will remain open.
Example:
InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", 1024L, 4096L);
bucketName - Bucket name.objectName - Object name in the bucket.offset - Offset to read at.length - Length to read.InputStream containing the object's data.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic InputStream getObject(String bucketName, String objectName, Long offset, Long length, ServerSideEncryption sse) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
InputStream in the given bucket. The
InputStream must be closed after use else the connection will remain open.
Example:
InputStream stream = minioClient.getObject("my-bucketname", "my-objectname", 1024L, 4096L, sse);
bucketName - Bucket name.objectName - Object name in the bucket.offset - Offset to read at.length - Length to read.sse - Server side encryption.InputStream containing the object's data.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic void getObject(String bucketName, String objectName, String fileName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
Example:
minioClient.getObject("my-bucketname", "my-objectname", "photo.jpg");bucketName - Bucket name.objectName - Object name in the bucket.fileName - file name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic void getObject(String bucketName, String objectName, ServerSideEncryption sse, String fileName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
Example:
minioClient.getObject("my-bucketname", "my-objectname", sse, "photo.jpg");bucketName - Bucket name.objectName - Object name in the bucket.sse - encryption metadata.fileName - file name to download into.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic void copyObject(String bucketName, String objectName, Map<String,String> headerMap, ServerSideEncryption sse, String srcBucketName, String srcObjectName, ServerSideEncryption srcSse, CopyConditions copyConditions) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, ErrorResponseException, InternalException, IOException, XmlParserException, IllegalArgumentException, InvalidResponseException
Example:
minioClient.copyObject("my-bucketname", "my-objectname", headers, sse, "my-srcbucketname","my-srcobjname", srcSse, copyConditions);
bucketName - Destination bucket name.objectName - Destination object name.headerMap - Destination object custom metadata.sse - Server side encryption of destination object.srcBucketName - Source bucket name.srcObjectName - Source object name.srcSse - Server side encryption of source object.copyConditions - CopyConditions object with collection of supported CopyObject conditions.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic void composeObject(String bucketName, String objectName, List<ComposeSource> sources, Map<String,String> headerMap, ServerSideEncryption sse) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
Example:
minioClient.composeObject("my-bucketname", "my-objectname", composeSources, userMetaData, sse);
bucketName - Destination Bucket to be created upon compose.objectName - Destination Object to be created upon compose.sources - List of Source Objects used to compose Object.headerMap - User Meta data.sse - Server Side Encryption.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic String getPresignedObjectUrl(Method method, String bucketName, String objectName, Integer expires, Map<String,String> reqParams) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidExpiresRangeException, InvalidResponseException
Example:
String url = minioClient.getPresignedObjectUrl(Method.DELETE, "my-bucketname", "my-objectname", 60 * 60 * 24, reqParams);
method - HTTP Method.bucketName - Bucket name.objectName - Object name in the bucket.expires - Expiration time in seconds of presigned URL.reqParams - Override values for set of response headers. Currently supported request
parameters are [response-expires, response-content-type, response-cache-control,
response-content-disposition]InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidExpiresRangeException - upon input expires is out of rangeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic String presignedGetObject(String bucketName, String objectName, Integer expires, Map<String,String> reqParams) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidExpiresRangeException, InvalidResponseException
Example:
String url = minioClient.presignedGetObject("my-bucketname", "my-objectname", 60 * 60 * 24, reqParams);
bucketName - Bucket name.objectName - Object name in the bucket.expires - Expiration time in seconds of presigned URL.reqParams - Override values for set of response headers. Currently supported request
parameters are [response-expires, response-content-type, response-cache-control,
response-content-disposition]InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidExpiresRangeException - upon input expires is out of rangeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic String presignedGetObject(String bucketName, String objectName, Integer expires) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidExpiresRangeException, InvalidResponseException
Example:
String url = minioClient.presignedGetObject("my-bucketname", "my-objectname", 60 * 60 * 24);
bucketName - Bucket name.objectName - Object name in the bucket.expires - Expiration time in seconds of presigned URL.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidExpiresRangeException - upon input expires is out of rangeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic String presignedGetObject(String bucketName, String objectName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidExpiresRangeException, InvalidResponseException
Example:
String url = minioClient.presignedGetObject("my-bucketname", "my-objectname");
bucketName - Bucket name.objectName - Object name in the bucket.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidExpiresRangeException - upon input expires is out of rangeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic String presignedPutObject(String bucketName, String objectName, Integer expires) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidExpiresRangeException, InvalidResponseException
Example:
String url = minioClient.presignedPutObject("my-bucketname", "my-objectname", 60 * 60 * 24);
bucketName - Bucket nameobjectName - Object name in the bucketexpires - Expiration time in seconds to presigned URL.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidExpiresRangeException - upon input expires is out of rangeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic String presignedPutObject(String bucketName, String objectName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidExpiresRangeException, InvalidResponseException
Example:
String url = minioClient.presignedPutObject("my-bucketname", "my-objectname");
bucketName - Bucket name.objectName - Object name in the bucket.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidExpiresRangeException - upon input expires is out of rangeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic Map<String,String> presignedPostPolicy(PostPolicy policy) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
PostPolicy to upload object with various post policy
conditions.
Example:
PostPolicy policy = new PostPolicy("my-bucketname", "my-objectname", ZonedDateTime.now().plusDays(7));
// 'my-objectname' should be 'image/png' content type
policy.setContentType("image/png");
// set success action status to 201 to receive XML document
policy.setSuccessActionStatus(201);
Map<String,String> formData = minioClient.presignedPostPolicy(policy);
// Print curl command to be executed by anonymous user to upload /tmp/userpic.png.
System.out.print("curl -X POST ");
for (Map.Entry<String,String> entry : formData.entrySet()) {
System.out.print(" -F " + entry.getKey() + "=" + entry.getValue());
}
System.out.println(" -F file=@/tmp/userpic.png https://play.min.io/my-bucketname");policy - Post policy of an object.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverPostPolicypublic void removeObject(String bucketName, String objectName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
Example:
minioClient.removeObject("my-bucketname", "my-objectname");bucketName - Bucket name.objectName - Object name in the bucket.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic Iterable<Result<DeleteError>> removeObjects(String bucketName, Iterable<String> objectNames)
Example:
List<String> myObjectNames = new LinkedList<String>();
objectNames.add("my-objectname1");
objectNames.add("my-objectname2");
objectNames.add("my-objectname3");
Iterable<Result<DeleteError>> results = minioClient.removeObjects("my-bucketname", myObjectNames);
for (Result<DeleteError> result : results) {
DeleteError error = errorResult.get();
System.out.println("Error in deleting object " + error.objectName() + "; " + error.message());
}bucketName - Bucket name.objectNames - List of Object names in the bucket.public Iterable<Result<Item>> listObjects(String bucketName) throws XmlParserException
Example:
Iterable<Result<Item>> results = minioClient.listObjects("my-bucketname");
for (Result<Item> result : results) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}bucketName - Bucket name.XmlParserException - upon parsing response xmlpublic Iterable<Result<Item>> listObjects(String bucketName, String prefix) throws XmlParserException
Example:
Iterable<Result<Item>> results = minioClient.listObjects("my-bucketname", "my-obj");
for (Result<Item> result : results) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}bucketName - Bucket name.prefix - Prefix string. List objects whose name starts with `prefix`.XmlParserException - upon parsing response xmlpublic Iterable<Result<Item>> listObjects(String bucketName, String prefix, boolean recursive)
Iterable<Result><Item> in given bucket, prefix and
recursive flag.
Example:
Iterable<Result<Item>> results = minioClient.listObjects("my-bucketname", "my-obj", true);
for (Result<Item> result : results) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}bucketName - Bucket name.prefix - Prefix string. List objects whose name starts with `prefix`.recursive - when false, emulates a directory structure where each listing returned is
either a full object or part of the object's key up to the first '/'. All objects wit the
same prefix up to the first '/' will be merged into one entry.listObjects(String bucketName),
listObjects(String bucketName, String prefix),
listObjects(String bucketName, String prefix, boolean recursive, boolean useVersion1)public Iterable<Result<Item>> listObjects(String bucketName, String prefix, boolean recursive, boolean useVersion1)
Iterable<Result><Item> in given bucket, prefix, recursive
flag and S3 API version to use.
Example:
Iterable<Result<Item>> results = minioClient.listObjects("my-bucketname", "my-obj", true, true);
for (Result<Item> result : results) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}bucketName - Bucket name.prefix - Prefix string. List objects whose name starts with `prefix`.recursive - when false, emulates a directory structure where each listing returned is
either a full object or part of the object's key up to the first '/'. All objects wit the
same prefix up to the first '/' will be merged into one entry.useVersion1 - If set, Amazon AWS S3 List Object V1 is used, else List Object V2 is used as
default.listObjects(String bucketName),
listObjects(String bucketName, String prefix),
listObjects(String bucketName, String prefix, boolean recursive)public Iterable<Result<Item>> listObjects(String bucketName, String prefix, boolean recursive, boolean includeUserMetadata, boolean useVersion1)
Iterable<Result><Item> in given bucket, prefix, recursive
flag, user metadata flag and S3 API version to use.
Example:
Iterable<Result<Item>> results = minioClient.listObjects("my-bucketname", "my-obj", true, true, false);
for (Result<Item> result : results) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
}bucketName - Bucket name.prefix - Prefix string. List objects whose name starts with `prefix`.recursive - when false, emulates a directory structure where each listing returned is
either a full object or part of the object's key up to the first '/'. All objects wit the
same prefix up to the first '/' will be merged into one entry.includeUserMetadata - include user metadata of each object. This is MinIO specific
extension to ListObjectsV2.useVersion1 - If set, Amazon AWS S3 List Object V1 is used, else List Object V2 is used as
default.listObjects(String bucketName),
listObjects(String bucketName, String prefix),
listObjects(String bucketName, String prefix, boolean recursive)public List<Bucket> listBuckets() throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
List<Bucket> bucketList = minioClient.listBuckets();
for (Bucket bucket : bucketList) {
System.out.println(bucket.creationDate() + ", " + bucket.name());
}InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading givenIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic boolean bucketExists(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
boolean found = minioClient.bucketExists("my-bucketname");
if (found) {
System.out.println("my-bucketname exists");
} else {
System.out.println("my-bucketname does not exist");
}bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading givenIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void makeBucket(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, RegionConflictException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
boolean found = minioClient.makeBucket("my-bucketname");bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenRegionConflictException - upon passed region conflicts with the one previously specifiedNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful execution.ErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInsufficientDataException - upon getting EOFException while reading givenInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void makeBucket(String bucketName, String region) throws InvalidBucketNameException, IllegalArgumentException, RegionConflictException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
boolean found = minioClient.makeBucket("my-bucketname", "eu-west-1");bucketName - Bucket name.region - region in which the bucket will be created.InvalidBucketNameException - upon invalid bucket name is givenRegionConflictException - upon passed region conflicts with the one previously specified.NoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInsufficientDataException - upon getting EOFException while reading givenInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void makeBucket(String bucketName, String region, boolean objectLock) throws InvalidBucketNameException, IllegalArgumentException, RegionConflictException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
boolean found = minioClient.makeBucket("my-bucketname", "eu-west-2", true);bucketName - Bucket name.region - region in which the bucket will be created.objectLock - enable object lock support.InvalidBucketNameException - upon invalid bucket name is givenRegionConflictException - upon passed region conflicts with the one previously specified.NoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInsufficientDataException - upon getting EOFException while reading givenInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void enableVersioning(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.enableVersioning("my-bucketname");bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInsufficientDataException - upon getting EOFException while reading givenInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void disableVersioning(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.disableVersioning("my-bucketname");bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInsufficientDataException - upon getting EOFException while reading givenInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void setDefaultRetention(String bucketName, ObjectLockConfiguration config) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.setDefaultRetention("my-bucketname", config);bucketName - Bucket name.config - Object lock configuration.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic ObjectLockConfiguration getDefaultRetention(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
ObjectLockConfiguration config = minioClient.getDefaultRetention("my-bucketname");
bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void setObjectRetention(String bucketName, String objectName, String versionId, Retention config, boolean bypassGovernanceRetention) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException, IllegalArgumentException
Example:
minioClient.setObjectRetention("my-bucketname", "my-object", null, config, true);
bucketName - Bucket name.objectName - Object name.versionId - Object versio id.config - Object lock configuration.bypassGovernanceRetention - By pass governance retention.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentException - upon invalid value is passed to a method.public Retention getObjectRetention(String bucketName, String objectName, String versionId) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
Retention retention = s3Client.getObjectRetention("my-bucketname", "my-objectname", null);
System.out.println("mode: " + retention.mode() + "until: " + retention.retainUntilDate());
bucketName - Bucket name.objectName - Object name.versionId - Version Id.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void enableObjectLegalHold(String bucketName, String objectName, String versionId) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.enableObjectLegalHold("my-bucketname", "my-object", null);bucketName - Bucket name.objectName - Object name.versionId - Object version id.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void disableObjectLegalHold(String bucketName, String objectName, String versionId) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.disableObjectLegalHold("my-bucketname", "my-object", null);bucketName - Bucket name.objectName - Object name.versionId - Object version id.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic boolean isObjectLegalHoldEnabled(String bucketName, String objectName, String versionId) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
boolean status = s3Client.isObjectLegalHoldEnabled("my-bucketname", "my-objectname", null);
if (status) {
System.out.println("Legal hold is on");
} else {
System.out.println("Legal hold is off");
}
bucketName - Bucket name.objectName - Object name.versionId - Object version id.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void removeBucket(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.removeBucket("my-bucketname");bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InsufficientDataException - upon getting EOFException while reading givenInvalidResponseException - upon a non-xml response from serverpublic void putObject(String bucketName, String objectName, String filename, PutObjectOptions options) throws InvalidBucketNameException, NoSuchAlgorithmException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InsufficientDataException, InvalidResponseException
Example:
PutObjectOptions options = new PutObjectOptions(7003256, -1);
minioClient.putObject("my-bucketname", "my-objectname", "trip.mp4", options);
bucketName - Bucket name.objectName - Object name to create in the bucket.filename - Name of file to upload.options - Options to be used during object upload.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic void putObject(String bucketName, String objectName, InputStream stream, PutObjectOptions options) throws InvalidBucketNameException, NoSuchAlgorithmException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InsufficientDataException, InvalidResponseException
Example:
PutObjectOptions options = new PutObjectOptions(7003256, -1);
minioClient.putObject("my-bucketname", "my-objectname", inputStream, options);
bucketName - Bucket name.objectName - Object name to create in the bucket.stream - Stream to upload.options - Options to be used during object upload.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic String getBucketPolicy(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, BucketPolicyTooLargeException, InvalidResponseException
Example:
String config = minioClient.getBucketPolicy("my-bucketname");
System.out.println("Bucket policy: " + config);bucketName - the name of the bucket for which policies are to be listed.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorBucketPolicyTooLargeException - upon bucket policy too large in sizeInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void setBucketPolicy(String bucketName, String policy) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
// Assume policyJson contains below JSON string;
// {
// "Statement": [
// {
// "Action": [
// "s3:GetBucketLocation",
// "s3:ListBucket"
// ],
// "Effect": "Allow",
// "Principal": "*",
// "Resource": "arn:aws:s3:::my-bucketname"
// },
// {
// "Action": "s3:GetObject",
// "Effect": "Allow",
// "Principal": "*",
// "Resource": "arn:aws:s3:::my-bucketname/myobject*"
// }
// ],
// "Version": "2012-10-17"
// }
//
minioClient.setBucketPolicy("my-bucketname", policyJson);bucketName - Bucket name.policy - Bucket policy JSON string.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void setBucketLifeCycle(String bucketName, String lifeCycle) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, IllegalArgumentException, InvalidResponseException
Example:
// Lets consider variable 'lifeCycleXml' contains below XML String;
// <LifecycleConfiguration>
// <Rule>
// <ID>expire-bucket</ID>
// <Prefix></Prefix>
// <Status>Enabled</Status>
// <Expiration>
// <Days>365</Days>
// </Expiration>
// </Rule>
// </LifecycleConfiguration>
//
minioClient.setBucketLifecycle("my-bucketname", lifeCycleXml);bucketName - Bucket name.lifeCycle - Bucket policy XML string.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorIllegalArgumentException - upon invalid value is passed to a method.InvalidResponseException - upon a non-xml response from serverpublic void deleteBucketLifeCycle(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
deleteBucketLifeCycle("my-bucketname");bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic String getBucketLifeCycle(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
String lifecycle = minioClient.getBucketLifecycle("my-bucketname");
System.out.println("Life cycle settings: " + lifecycle);bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic NotificationConfiguration getBucketNotification(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
NotificationConfiguration config = minioClient.getBucketNotification("my-bucketname");
System.out.println(config);bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void setBucketNotification(String bucketName, NotificationConfiguration notificationConfiguration) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
List<EventType> eventList = new LinkedList<>();
eventList.add(EventType.OBJECT_CREATED_PUT);
eventList.add(EventType.OBJECT_CREATED_COPY);
QueueConfiguration queueConfiguration = new QueueConfiguration();
queueConfiguration.setQueue("arn:minio:sqs::1:webhook");
queueConfiguration.setEvents(eventList);
queueConfiguration.setPrefixRule("images");
queueConfiguration.setSuffixRule("pg");
List<QueueConfiguration> queueConfigurationList = new LinkedList<>();
queueConfigurationList.add(queueConfiguration);
NotificationConfiguration config = new NotificationConfiguration();
config.setQueueConfigurationList(queueConfigurationList);
minioClient.setBucketNotification("my-bucketname", config);bucketName - Bucket name.notificationConfiguration - Notification configuration to be set.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic void removeAllBucketNotification(String bucketName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.removeAllBucketNotification("my-bucketname");bucketName - Bucket name.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic Iterable<Result<Upload>> listIncompleteUploads(String bucketName) throws XmlParserException
Example:
Iterable<Result<Upload>> results = minioClient.listIncompleteUploads("my-bucketname");
for (Result<Upload> result : results) {
Upload upload = result.get();
System.out.println(upload.uploadId() + ", " + upload.objectName());
}bucketName - Bucket name.XmlParserExceptionlistIncompleteUploads(String, String, boolean)public Iterable<Result<Upload>> listIncompleteUploads(String bucketName, String prefix) throws XmlParserException
Example:
Iterable<Result<Upload>> results = minioClient.listIncompleteUploads("my-bucketname", "my-obj");
for (Result<Upload> result : results) {
Upload upload = result.get();
System.out.println(upload.uploadId() + ", " + upload.objectName());
}bucketName - Bucket name.prefix - filters the list of uploads to include only those that start with prefix.XmlParserException - upon parsing response xmllistIncompleteUploads(String, String, boolean)public Iterable<Result<Upload>> listIncompleteUploads(String bucketName, String prefix, boolean recursive)
Example:
Iterable<Result<Upload>> results = minioClient.listIncompleteUploads("my-bucketname", "my-obj", true);
for (Result<Upload> result : results) {
Upload upload = result.get();
System.out.println(upload.uploadId() + ", " + upload.objectName());
}bucketName - Bucket name.prefix - Prefix string. List objects whose name starts with `prefix`.recursive - when false, emulates a directory structure where each listing returned is
either a full object or part of the object's key up to the first '/'. All uploads with the
same prefix up to the first '/' will be merged into one entry.listIncompleteUploads(String bucketName),
listIncompleteUploads(String bucketName, String prefix)public void removeIncompleteUpload(String bucketName, String objectName) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
minioClient.removeIncompleteUpload("my-bucketname", "my-objectname");bucketName - Bucket name.objectName - Object name in the bucket.InvalidBucketNameException - upon invalid bucket name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverIllegalArgumentExceptionpublic CloseableIterator<Result<NotificationRecords>> listenBucketNotification(String bucketName, String prefix, String suffix, String[] events) throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException, InvalidResponseException, InternalException, InvalidBucketNameException, XmlParserException, ErrorResponseException
Example:
String[] events = {"s3:ObjectCreated:*", "s3:ObjectAccessed:*"};
try (CloseableIterator<Result<NotificationInfo>> ci =
minioClient.listenBucketNotification("bcketName", "", "", events)) {
while (ci.hasNext()) {
NotificationRecords records = ci.next().get();
for (Event event : records.events()) {
System.out.println("Event " + event.eventType() + " occurred at " + event.eventTime()
+ " for " + event.bucketName() + "/" + event.objectName());
}
}
}bucketName - Bucket name.prefix - Prefix of concerned objects events.suffix - Suffix of concerned objects events.events - List of events to watch.IOExceptionInvalidKeyExceptionNoSuchAlgorithmExceptionInsufficientDataExceptionInvalidResponseExceptionInternalExceptionInvalidBucketNameExceptionXmlParserExceptionErrorResponseExceptionpublic SelectResponseStream selectObjectContent(String bucketName, String objectName, String sqlExpression, InputSerialization is, OutputSerialization os, boolean requestProgress, Long scanStartRange, Long scanEndRange, ServerSideEncryption sse) throws InvalidBucketNameException, IllegalArgumentException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, XmlParserException, ErrorResponseException, InternalException, InvalidResponseException
Example:
String sqlExpression = "select * from S3Object";
InputSerialization is = new InputSerialization(null, false, null, null, FileHeaderInfo.USE, null, null, null);
OutputSerialization os = new OutputSerialization(null, null, null, QuoteFields.ASNEEDED, null);
SelectResponseStream stream = minioClient.selectObjectContent("my-bucketname", "my-objectName", sqlExpression,
is, os, true, null, null, null);
byte[] buf = new byte[512];
int bytesRead = stream.read(buf, 0, buf.length);
System.out.println(new String(buf, 0, bytesRead, StandardCharsets.UTF_8));
Stats stats = stream.stats();
System.out.println("bytes scanned: " + stats.bytesScanned());
System.out.println("bytes processed: " + stats.bytesProcessed());
System.out.println("bytes returned: " + stats.bytesReturned());
stream.close();bucketName - Bucket name.objectName - Object name.sqlExpression - SQL expression.is - Input serialization.os - Output serialization.requestProgress - Request progress in response.scanStartRange - scan start range.scanEndRange - scan end range.sse - Server side encryption.InvalidBucketNameException - upon invalid bucket name is givenIllegalArgumentException - upon empty object name is givenNoSuchAlgorithmException - upon requested algorithm was not found during signature
calculationInsufficientDataException - upon getting EOFException while reading given InputStream
even before reading given lengthIOException - upon connection errorInvalidKeyException - upon an invalid access key or secret keyXmlParserException - upon parsing response xmlErrorResponseException - upon unsuccessful executionInternalException - upon internal library errorInvalidResponseException - upon a non-xml response from serverpublic 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 NoSuchAlgorithmException,
KeyManagementException
Example:
minioClient.ignoreCertCheck();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)