Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MinIO Client SDK for Java

License

NotificationsYou must be signed in to change notification settings

minio/minio-java

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.

Minimum Requirements

Java 1.8 or above.

Maven usage

<dependency>    <groupId>io.minio</groupId>    <artifactId>minio</artifactId>    <version>8.6.0</version></dependency>

Gradle usage

dependencies {    implementation("io.minio:minio:8.6.0")}

JAR download

The latest JAR can be downloaded fromhere

Quick Start Example - File Uploader

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.

ParametersDescription
EndpointURL to S3 service.
Access KeyAccess key (aka user ID) of an account in the S3 service.
Secret KeySecret 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.

FileUploader.java

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

Compile FileUploader

$ javac -cp minio-8.6.0-all.jar FileUploader.java

Run FileUploader

$ 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

More References

Explore Further

Contribute

Please referContributors Guide


[8]ページ先頭

©2009-2025 Movatter.jp