MinIO安装、部署、开发⽂档、完整API参考⽂档⽬录
微软Windows系统
下载⼆进制⽂件
操作系统CPU架构地址
微软Windows系统64位
Copy
< server D:\Photos
GNU/Linux
下载⼆进制⽂件
操作系统CPU架构地址
GNU/Linux64-bit Intel
Copy
chmod +x minio
./minio server /data
最低需求
Java 1.8或更⾼版本:
使⽤maven
Copy
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>3.0.10</version>
</dependency>
使⽤gradle
Copy
dependencies {
compile 'io.minio:minio:3.0.10'
}
直接下载JAR
你可以到maven仓库直接下载最新版的。
快速⼊门⽰例-⽂件上传
本⽰例程序连接到⼀个对象存储服务,创建⼀个存储桶并上传⼀个⽂件到该桶中。
你需要有存储服务的三个参数才能连接到该服务。
参数说明
Endpoint对象存储服务的URL
Access Key Access key就像⽤户ID,可以唯⼀标识你的账户。
Secret Key Secret key是你账户的密码。
FileUploader.java
Copy
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
lpull.v1.XmlPullParserException;
import io.minio.MinioClient;
import s.MinioException;
public class FileUploader {
public static void main(String[] args) throws NoSuchAlgorithmException, IOException, InvalidKeyException, XmlPullParserException {
try {
// 使⽤MinIO服务的URL,端⼝,Access key和Secret key创建⼀个MinioClient对象
MinioClient minioClient = new MinioClient("play.min.io", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
// 检查存储桶是否已经存在
boolean isExist = minioClient.bucketExists("asiatrip");
if(isExist) {
System.out.println("Bucket already exists.");
} else {
// 创建⼀个名为asiatrip的存储桶,⽤于存储照⽚的zip⽂件。
minioClient.makeBucket("asiatrip");
}
// 使⽤putObject上传⼀个⽂件到存储桶中。
minioClient.putObject("asiatrip","asiaphotos.zip", "/home/user/Photos/asiaphotos.zip");
System.out.println("/home/user/Photos/asiaphotos.zip is successfully uploaded as asiaphotos.zip to `asiatrip` bucket.");
} catch(MinioException e) {
System.out.println("Error occurred: " + e);
}
}
}
编译FileUploader
Copy
javac -cp "minio-3.0.9-all.jar"  FileUploader.java
运⾏FileUploader
Copy
java -cp "minio-3.0.9-all.jar:." FileUploader
/home/user/Photos/asiaphotos.zip is successfully uploaded as asiaphotos.zip to `asiatrip` bucket.
mc ls play/asiatrip/
[2016-06-02 18:10:29 PDT]  82KiB asiaphotos.zip
API⽂档
下⾯是完整的API⽂档
初始化Minio Client object。
MinIO
Copy
MinioClient minioClient = new MinioClient("play.min.io", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); AWS S3
Copy
MinioClient s3Client = new MinioClient("s3.amazonaws", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");
存储桶操作⽂件对象操作Presigned操作存储桶策略
1. 构造函数
public MinioClient(String endpoint) throws NullPointerException, InvalidEndpointException, InvalidPo
rtException
使⽤给定的endpoint以及匿名⽅式创建⼀个Minio client对象。
public MinioClient(URL url) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的url以及匿名⽅式创建⼀个Minio client对象。
public MinioClient(com.squareup.okhttp.HttpUrl url) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的HttpUrl以及匿名⽅式创建⼀个Minio client对象。
public MinioClient(String endpoint, String accessKey, String secretKey) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的endpoint、access key和secret key创建⼀个Minio client对象。
public MinioClient(String endpoint, int port, String accessKey, String secretKey) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的endpoint、port、access key和secret key创建⼀个Minio client对象。
public MinioClient(String endpoint, String accessKey, String secretKey, boolean secure) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的endpoint、access key、secret key和⼀个secure选项(是否使⽤https)创建⼀个Minio client对象。
public MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的endpoint、port、access key、secret key和⼀个secure选项(是否使⽤https)创建⼀个Minio client对象。
public MinioClient(com.squareup.okhttp.HttpUrl url, String accessKey, String secretKey) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的HttpUrl对象、access key、secret key创建⼀个Minio client对象。
public MinioClient(URL url, String accessKey, String secretKey) throws NullPointerException, InvalidEndpointException, InvalidPortException
使⽤给定的URL对象、access key、secret key创建⼀个Minio client对象。
参数
参数类型描述
endpoint string endPoint是⼀个URL,域名,IPv4或者IPv6地址。以下是合法的endpoints:
localhost
play.min.io
port int TCP/IP端⼝号。可选,默认值是,如果是http,则默认80端⼝,如果是https,则默认是443端⼝。
accessKey string accessKey类似于⽤户ID,⽤于唯⼀标识你的账户。
参数类型描述
secretKey string secretKey是你账户的密码。
secure boolean如果是true,则⽤的是https⽽不是http,默认值是true。
url URL Endpoint URL对象。
url HttpURL Endpoint HttpUrl对象。
⽰例
MinIO
Copy
// 1. public MinioClient(String endpoint)
MinioClient minioClient = new MinioClient("play.min.io");
error parse new// 2. public MinioClient(URL url)
MinioClient minioClient = new MinioClient(new URL("play.min.io"));
// 3. public MinioClient(com.squareup.okhttp.HttpUrl url)
MinioClient minioClient = new MinioClient(new HttpUrl.parse("play.min.io"));
/
/ 4. public MinioClient(String endpoint, String accessKey, String secretKey)
MinioClient minioClient = new MinioClient("play.min.io", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
// 5. public MinioClient(String endpoint, int port,  String accessKey, String secretKey)
MinioClient minioClient = new MinioClient("play.min.io", 9000, "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
// 6. public MinioClient(String endpoint, String accessKey, String secretKey, boolean insecure)
MinioClient minioClient = new MinioClient("play.min.io", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true);
// 7. public MinioClient(String endpoint, int port,  String accessKey, String secretKey, boolean insecure)
MinioClient minioClient = new MinioClient("play.min.io", 9000, "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", true);
// 8. public MinioClient(com.squareup.okhttp.HttpUrl url, String accessKey, String secretKey)
MinioClient minioClient = new MinioClient(new URL("play.min.io"), "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
// 9. public MinioClient(URL url, String accessKey, String secretKey)
MinioClient minioClient = new MinioClient(HttpUrl.parse("play.min.io"), "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); AWS S3

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。