Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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](https://min.io/docs/minio/linux/developers/java/API.html) documentation.
For a complete list of APIs and examples, please take a look at the [Java Client API Reference](https://docs.min.io/enterprise/aistor-object-store/developers/sdk/java/api/) documentation.

## Minimum Requirements
Java 1.8 or above.
Expand Down Expand Up @@ -105,12 +105,12 @@ $ mc ls play/asiatrip/
```

## More References
* [Java Client API Reference](https://min.io/docs/minio/linux/developers/java/API.html)
* [Java Client API Reference](https://docs.min.io/enterprise/aistor-object-store/developers/sdk/java/api/)
* [Javadoc](https://minio-java.min.io/)
* [Examples](https://github.com/minio/minio-java/tree/release/examples)

## Explore Further
* [Complete Documentation](https://min.io/docs/minio/kubernetes/upstream/index.html)
* [Complete Documentation](https://docs.min.io/enterprise/aistor-object-store/)
* [Build your own Photo API Service - Full Application Example ](https://github.com/minio/minio-java-rest-example)

## Contribute
Expand Down
33 changes: 26 additions & 7 deletions api/src/main/java/io/minio/BaseS3Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ private void onResponse(final Response response) throws IOException {
code = result[0];
message = result[1];
break;
case 403:
code = "AccessDenied";
message = "Access denied";
break;
case 404:
if (s3request.object() != null) {
code = "NoSuchKey";
Expand All @@ -425,8 +429,8 @@ private void onResponse(final Response response) throws IOException {
message = "Request resource not found";
}
break;
case 501:
case 405:
case 501:
code = "MethodNotAllowed";
message = "The specified method is not allowed against this resource";
break;
Expand All @@ -439,10 +443,6 @@ private void onResponse(final Response response) throws IOException {
message = "Request resource conflicts";
}
break;
case 403:
code = "AccessDenied";
message = "Access denied";
break;
case 412:
code = "PreconditionFailed";
message = "At least one of the preconditions you specified did not hold";
Expand Down Expand Up @@ -664,13 +664,18 @@ public CompletableFuture<AbortMultipartUploadResponse> abortMultipartUpload(
public CompletableFuture<ObjectWriteResponse> completeMultipartUpload(
CompleteMultipartUploadArgs args) {
checkArgs(args);
args.validateSsec(baseUrl.isHttps());
Http.Body body = null;
try {
body = new Http.Body(new CompleteMultipartUpload(args.parts()), null, null, null);
} catch (MinioException e) {
return Utils.failedFuture(e);
}
return executePostAsync(args, null, new Http.QueryParameters(UPLOAD_ID, args.uploadId()), body)
return executePostAsync(
args,
args.ssec() == null ? null : args.ssec().headers(),
new Http.QueryParameters(UPLOAD_ID, args.uploadId()),
body)
.thenApply(
response -> {
try {
Expand Down Expand Up @@ -802,7 +807,7 @@ public CompletableFuture<GenericResponse> createBucket(CreateBucketArgs args) {
if (locationConstraint.equals(Http.US_EAST_1)) {
config =
new CreateBucketConfiguration(
locationConstraint, args.locationConfig(), args.bucketConfig());
locationConstraint, args.locationConfig(), args.bucketConfig(), args.tags());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small doubt here. Tags are only passed to US_EAST_1. What about other regions? Don't we need to pass it?

}

Http.Body body = null;
Expand Down Expand Up @@ -951,6 +956,20 @@ public CompletableFuture<String> getBucketLocation(GetBucketLocationArgs args) {
});
}

/**
* Do <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html">HeadBucket S3
* API</a> asynchronously.
*
* @param args {@link HeadBucketArgs} object.
* @return {@link CompletableFuture}&lt;{@link HeadBucketResponse}&gt; object.
*/
public CompletableFuture<HeadBucketResponse> headBucket(HeadBucketArgs args) {
checkArgs(args);
return executeHeadAsync(args, null, null)
.thenApply(
response -> new HeadBucketResponse(response.headers(), args.bucket(), args.region()));
}

/**
* Do <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html">HeadObject S3
* API</a> asynchronously.
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/io/minio/BucketExistsArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package io.minio;

/** Arguments of {@link MinioAsyncClient#bucketExists} and {@link MinioClient#bucketExists}. */
public class BucketExistsArgs extends BucketArgs {
public class BucketExistsArgs extends HeadBucketBaseArgs {
public static Builder builder() {
return new Builder();
}

/** Builder of {@link BucketExistsArgs}. */
public static final class Builder extends BucketArgs.Builder<Builder, BucketExistsArgs> {}
public static final class Builder extends HeadBucketBaseArgs.Builder<Builder, BucketExistsArgs> {}
}
23 changes: 21 additions & 2 deletions api/src/main/java/io/minio/CompleteMultipartUploadArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class CompleteMultipartUploadArgs extends ObjectArgs {
private String uploadId;
private Part[] parts;
private ServerSideEncryption.CustomerKey ssec;

protected CompleteMultipartUploadArgs() {}

Expand All @@ -37,6 +38,9 @@ public CompleteMultipartUploadArgs(PutObjectBaseArgs args, String uploadId, Part
super(args);
this.uploadId = uploadId;
this.parts = parts;
if (args.sse() != null && args.sse() instanceof ServerSideEncryption.CustomerKey) {
this.ssec = (ServerSideEncryption.CustomerKey) args.sse();
}
}

public String uploadId() {
Expand All @@ -47,6 +51,14 @@ public Part[] parts() {
return parts;
}

public ServerSideEncryption.CustomerKey ssec() {
return ssec;
}

public void validateSsec(boolean isHttps) {
checkSse(ssec, isHttps);
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -72,6 +84,11 @@ public Builder parts(Part[] parts) {
operations.add(args -> args.parts = parts);
return this;
}

public Builder ssec(ServerSideEncryption.CustomerKey ssec) {
operations.add(args -> args.ssec = ssec);
return this;
}
}

@Override
Expand All @@ -80,11 +97,13 @@ public boolean equals(Object o) {
if (!(o instanceof CompleteMultipartUploadArgs)) return false;
if (!super.equals(o)) return false;
CompleteMultipartUploadArgs that = (CompleteMultipartUploadArgs) o;
return Objects.equals(uploadId, that.uploadId) && Arrays.equals(parts, that.parts);
return Objects.equals(uploadId, that.uploadId)
&& Arrays.equals(parts, that.parts)
&& Objects.equals(ssec, that.ssec);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), uploadId, parts);
return Objects.hash(super.hashCode(), uploadId, parts, ssec);
}
}
17 changes: 15 additions & 2 deletions api/src/main/java/io/minio/CreateBucketBaseArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package io.minio;

import io.minio.messages.CreateBucketConfiguration;
import io.minio.messages.Tags;
import java.util.Objects;

/** Common arguments of {@link CreateBucketArgs} and {@link MakeBucketArgs}. */
public abstract class CreateBucketBaseArgs extends BucketArgs {
protected boolean objectLock;
protected CreateBucketConfiguration.Location locationConfig;
protected CreateBucketConfiguration.Bucket bucket;
protected Tags tags;

protected CreateBucketBaseArgs() {}

Expand All @@ -32,6 +34,7 @@ protected CreateBucketBaseArgs(CreateBucketBaseArgs args) {
this.objectLock = args.objectLock;
this.locationConfig = args.locationConfig;
this.bucket = args.bucket;
this.tags = args.tags;
}

public boolean objectLock() {
Expand All @@ -46,6 +49,10 @@ public CreateBucketConfiguration.Bucket bucketConfig() {
return bucket;
}

public Tags tags() {
return tags;
}

/** Base argument builder of {@link CreateBucketBaseArgs}. */
@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public abstract static class Builder<B extends Builder<B, A>, A extends CreateBucketBaseArgs>
Expand All @@ -69,6 +76,11 @@ public B bucketConfig(CreateBucketConfiguration.Bucket bucket) {
operations.add(args -> args.bucket = bucket);
return (B) this;
}

public B tags(Tags tags) {
operations.add(args -> args.tags = tags);
return (B) this;
}
}

@Override
Expand All @@ -79,11 +91,12 @@ public boolean equals(Object o) {
CreateBucketBaseArgs that = (CreateBucketBaseArgs) o;
return objectLock == that.objectLock
&& Objects.equals(locationConfig, that.locationConfig)
&& Objects.equals(bucket, that.bucket);
&& Objects.equals(bucket, that.bucket)
&& Objects.equals(tags, that.tags);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), objectLock, locationConfig, bucket);
return Objects.hash(super.hashCode(), objectLock, locationConfig, bucket, tags);
}
}
60 changes: 57 additions & 3 deletions api/src/main/java/io/minio/DownloadObjectArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.minio;

import java.time.ZonedDateTime;
import java.util.Objects;

/**
Expand All @@ -25,6 +26,10 @@
public class DownloadObjectArgs extends ObjectReadArgs {
private String filename;
private boolean overwrite;
protected String matchETag;
protected String notMatchETag;
protected ZonedDateTime modifiedSince;
protected ZonedDateTime unmodifiedSince;

public String filename() {
return filename;
Expand All @@ -34,6 +39,22 @@ public boolean overwrite() {
return overwrite;
}

public String matchETag() {
return matchETag;
}

public String notMatchETag() {
return notMatchETag;
}

public ZonedDateTime modifiedSince() {
return modifiedSince;
}

public ZonedDateTime unmodifiedSince() {
return unmodifiedSince;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -54,6 +75,28 @@ public Builder overwrite(boolean flag) {
operations.add(args -> args.overwrite = flag);
return this;
}

public Builder matchETag(String etag) {
Utils.validateNullOrNotEmptyString(etag, "etag");
operations.add(args -> args.matchETag = etag);
return this;
}

public Builder notMatchETag(String etag) {
Utils.validateNullOrNotEmptyString(etag, "etag");
operations.add(args -> args.notMatchETag = etag);
return this;
}

public Builder modifiedSince(ZonedDateTime modifiedTime) {
operations.add(args -> args.modifiedSince = modifiedTime);
return this;
}

public Builder unmodifiedSince(ZonedDateTime unmodifiedTime) {
operations.add(args -> args.unmodifiedSince = unmodifiedTime);
return this;
}
}

@Override
Expand All @@ -62,12 +105,23 @@ public boolean equals(Object o) {
if (!(o instanceof DownloadObjectArgs)) return false;
if (!super.equals(o)) return false;
DownloadObjectArgs that = (DownloadObjectArgs) o;
if (!Objects.equals(filename, that.filename)) return false;
return overwrite == that.overwrite;
return Objects.equals(filename, that.filename)
&& overwrite == that.overwrite
&& Objects.equals(matchETag, that.matchETag)
&& Objects.equals(notMatchETag, that.notMatchETag)
&& Objects.equals(modifiedSince, that.modifiedSince)
&& Objects.equals(unmodifiedSince, that.unmodifiedSince);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), filename, overwrite);
return Objects.hash(
super.hashCode(),
filename,
overwrite,
matchETag,
notMatchETag,
modifiedSince,
unmodifiedSince);
}
}
7 changes: 7 additions & 0 deletions api/src/main/java/io/minio/GenericUploadResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

import io.minio.messages.CompleteMultipartUploadResult;
import io.minio.messages.CopyObjectResult;
import java.time.ZonedDateTime;
import okhttp3.Headers;

/** Common response of {@link ObjectWriteResponse} and {@link PutObjectFanOutResponse}. */
public class GenericUploadResponse extends GenericResponse {
private String etag;
private ZonedDateTime lastModified;
private String checksumCRC32;
private String checksumCRC32C;
private String checksumCRC64NVME;
Expand Down Expand Up @@ -54,6 +56,7 @@ public GenericUploadResponse(
super(headers, bucket, region, object);
this.etag = etag;
if (result != null) {
this.lastModified = result.lastModified();
this.checksumType = result.checksumType();
this.checksumCRC32 = result.checksumCRC32();
this.checksumCRC32C = result.checksumCRC32C();
Expand Down Expand Up @@ -86,6 +89,10 @@ public String etag() {
return etag;
}

public ZonedDateTime lastModified() {
return lastModified;
}

public String checksumCRC32() {
return checksumCRC32;
}
Expand Down
Loading
Loading