- Notifications
You must be signed in to change notification settings - Fork508
minio/minio-java
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
MinIO Java SDK is Simple Storage Service (aka S3) client to perform bucket and object operations to any Amazon S3 compatible object storage service.
For a complete list of APIs and examples, please take a look at theJava Client API Reference documentation.
Java 1.8 or above.
<dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.6.0</version></dependency>
dependencies { implementation("io.minio:minio:8.6.0")}The latest JAR can be downloaded fromhere
This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket.
You need three items in order to connect to an object storage server.
| Parameters | Description |
|---|---|
| Endpoint | URL to S3 service. |
| Access Key | Access key (aka user ID) of an account in the S3 service. |
| Secret Key | Secret key (aka password) of an account in the S3 service. |
This example uses MinIO server playgroundhttps://play.min.io. Feel free to use this service for test and development.
importio.minio.BucketExistsArgs;importio.minio.MakeBucketArgs;importio.minio.MinioClient;importio.minio.UploadObjectArgs;importio.minio.errors.MinioException;importjava.io.IOException;importjava.security.InvalidKeyException;importjava.security.NoSuchAlgorithmException;publicclassFileUploader {publicstaticvoidmain(String[]args)throwsIOException,NoSuchAlgorithmException,InvalidKeyException {try {// Create a minioClient with the MinIO server playground, its access key and secret key.MinioClientminioClient =MinioClient.builder() .endpoint("https://play.min.io") .credentials("Q3AM3UQ867SPQQA43P2F","zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG") .build();// Make 'asiatrip' bucket if not exist.booleanfound =minioClient.bucketExists(BucketExistsArgs.builder().bucket("asiatrip").build());if (!found) {// Make a new bucket called 'asiatrip'.minioClient.makeBucket(MakeBucketArgs.builder().bucket("asiatrip").build()); }else {System.out.println("Bucket 'asiatrip' already exists."); }// Upload '/home/user/Photos/asiaphotos.zip' as object name 'asiaphotos-2015.zip' to bucket// 'asiatrip'.minioClient.uploadObject(UploadObjectArgs.builder() .bucket("asiatrip") .object("asiaphotos-2015.zip") .filename("/home/user/Photos/asiaphotos.zip") .build());System.out.println("'/home/user/Photos/asiaphotos.zip' is successfully uploaded as " +"object 'asiaphotos-2015.zip' to bucket 'asiatrip'."); }catch (MinioExceptione) {System.out.println("Error occurred: " +e);System.out.println("HTTP trace: " +e.httpTrace()); } }}
$ javac -cp minio-8.6.0-all.jar FileUploader.java
$ java -cp minio-8.6.0-all.jar:. FileUploader'/home/user/Photos/asiaphotos.zip' is successfully uploaded as object'asiaphotos-2015.zip' to bucket'asiatrip'.$ mc ls play/asiatrip/[2016-06-02 18:10:29 PDT] 82KiB asiaphotos-2015.zip
Please referContributors Guide
About
MinIO Client SDK for Java
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.