MinIO Client SDK for Java
Go to file
Bala FA d76a580185
upgrade gradle and dependencies (#1579)
Signed-off-by: Bala.FA <bala@minio.io>
2024-10-16 21:44:35 -07:00
.github/workflows upgrade gradle and dependencies (#1579) 2024-10-16 21:44:35 -07:00
adminapi/src fix getServerInfo Missing field & data accuracy error (#1516) 2024-02-10 16:40:59 -08:00
api/src add httpclient close option to minio client builder (#1587) 2024-10-14 09:34:32 -07:00
docs Add restoreObject API support (#1227) 2022-09-23 21:38:52 -07:00
examples Upgrade gradle, gradle dependencies and project dependencies (#1454) 2023-06-19 08:00:02 -07:00
functional Close HTTP client owned by MinioClient (#1546) 2024-04-13 18:29:12 -07:00
gradle/wrapper upgrade gradle and dependencies (#1579) 2024-10-16 21:44:35 -07:00
.gitattributes add .gitattributes for windows build (#1011) 2020-07-10 14:49:07 -07:00
.gitignore Add versioning support in listObjects API (#984) 2020-06-20 00:18:44 -07:00
build.gradle upgrade gradle and dependencies (#1579) 2024-10-16 21:44:35 -07:00
CONTRIBUTING.md fix README and CONTRIBUTING guides (#1132) 2020-12-17 18:32:46 -08:00
gradlew Upgrade gradle, it's dependencies and project dependencies (#1534) 2024-03-02 15:37:04 -08:00
gradlew.bat upgrade gradle and dependencies (#1579) 2024-10-16 21:44:35 -07:00
LICENSE Initial commit 2015-05-02 16:01:03 -07:00
MAINTAINERS.md Modifies minio.io --> min.io (#768) 2019-04-17 18:05:09 -07:00
README_zh_CN.md Updating links to documentation with new URLs (#1366) 2022-09-20 14:30:15 -07:00
README.md Release version 8.5.12 2024-08-17 13:24:51 +00:00
settings.gradle Simplify io.minio.admin package (#1236) 2021-09-22 19:23:02 -07:00
spotbugs-filter.xml Upgrade gradle, it's dependencies and project dependencies (#1507) 2023-11-04 19:26:00 -07:00

MinIO Java SDK for Amazon S3 Compatible Cloud Storage Slack

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 the Java Client API Reference documentation.

Minimum Requirements

Java 1.8 or above.

Maven usage

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

Gradle usage

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

JAR download

The latest JAR can be downloaded from here

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.

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 playground https://play.min.io. Feel free to use this service for test and development.

FileUploader.java

import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.UploadObjectArgs;
import io.minio.errors.MinioException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class FileUploader {
  public static void main(String[] args)
      throws IOException, NoSuchAlgorithmException, InvalidKeyException {
    try {
      // Create a minioClient with the MinIO server playground, its access key and secret key.
      MinioClient minioClient =
          MinioClient.builder()
              .endpoint("https://play.min.io")
              .credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
              .build();

      // Make 'asiatrip' bucket if not exist.
      boolean found =
          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 (MinioException e) {
      System.out.println("Error occurred: " + e);
      System.out.println("HTTP trace: " + e.httpTrace());
    }
  }
}

Compile FileUploader

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

Run FileUploader

$ java -cp minio-8.5.12-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 refer Contributors Guide