Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle SSE in copyObject() properly and have one source code. #777

Merged
merged 1 commit into from
Aug 4, 2019
Merged
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
209 changes: 139 additions & 70 deletions api/src/main/java/io/minio/MinioClient.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/CopyObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public static void main(String[] args)
bais.close();
System.out.println("my-objectname is uploaded successfully");

minioClient.copyObject("my-bucketname", "my-objectname", "my-destbucketname",
"my-objectname-copy");
minioClient.copyObject("my-destbucketname", "my-objectname-copy", null, null,
"my-bucketname", "my-objectname", null, null);
System.out.println("my-objectname-copy copied to my-destbucketname successfully");
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
Expand Down
4 changes: 2 additions & 2 deletions examples/CopyObjectEncrypted.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static void main(String[] args)
minioClient.putObject("my-bucketname", "my-objectname", bais, Long.valueOf(bais.available()), null, ssePut, null);
System.out.println("my-objectname is uploaded successfully");

minioClient.copyObject("my-bucketname", "my-objectname", sseSource, "my-destbucketname",
"my-objectname-copy", null, sseTarget);
minioClient.copyObject("my-destbucketname", "my-objectname-copy", null, sseTarget,
"my-bucketname", "my-objectname", sseSource, null);

bais.close();

Expand Down
6 changes: 3 additions & 3 deletions examples/CopyObjectEncryptedKms.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public static void main(String[] args)
bais.close();
System.out.println("my-objectname is uploaded successfully");

minioClient.copyObject("my-bucketname", "my-objectname", null, "my-destbucketname",
"my-objectname-copy", null, sse);
minioClient.copyObject("my-destbucketname", "my-objectname-copy", null, sse,
"my-bucketname", "my-objectname", null, null);
System.out.println("my-objectname-copy copied to my-destbucketname successfully");

} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
System.out.println("finished");
}
}
}
6 changes: 3 additions & 3 deletions examples/CopyObjectEncryptedS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public static void main(String[] args)
bais.close();
System.out.println("my-objectname is uploaded successfully");

minioClient.copyObject("my-bucketname", "my-objectname", null, "my-destbucketname",
"my-objectname-copy", null, sse);
minioClient.copyObject("my-destbucketname", "my-objectname-copy", null, sse,
"my-bucketname", "my-objectname", null, null);
System.out.println("my-objectname-copy copied to my-destbucketname successfully");
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
System.out.println("finished");
}
}
}
4 changes: 2 additions & 2 deletions examples/CopyObjectMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public static void main(String[] args)
Map<String, String> metadata = new HashMap<>();
metadata.put("Content-Type", "application/javascript");

minioClient.copyObject("my-bucketname", "my-objectname", "my-destbucketname",
"my-objectname-copy", copyConditions, metadata);
minioClient.copyObject("my-destbucketname", "my-objectname-copy", metadata, null,
"my-bucketname", "my-objectname", null, copyConditions);
System.out.println("my-objectname-copy copied to my-destbucketname successfully");
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
Expand Down
26 changes: 14 additions & 12 deletions functional/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ public static void copyObject_test1() throws Exception {

String destBucketName = getRandomName();
client.makeBucket(destBucketName);
client.copyObject(bucketName, objectName, destBucketName);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, null);
client.getObject(destBucketName, objectName).close();

client.removeObject(bucketName, objectName);
Expand Down Expand Up @@ -2048,7 +2048,7 @@ public static void copyObject_test2() throws Exception {
invalidETag.setMatchETag("TestETag");

try {
client.copyObject(bucketName, objectName, destBucketName, invalidETag);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, invalidETag);
} catch (ErrorResponseException e) {
if (!e.errorResponse().code().equals("PreconditionFailed")) {
throw e;
Expand Down Expand Up @@ -2094,7 +2094,7 @@ public static void copyObject_test3() throws Exception {
copyConditions.setMatchETag(stat.etag());

// File should be copied as ETag set in copyConditions matches object's ETag.
client.copyObject(bucketName, objectName, destBucketName, copyConditions);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, copyConditions);
client.getObject(destBucketName, objectName).close();

client.removeObject(bucketName, objectName);
Expand Down Expand Up @@ -2136,7 +2136,7 @@ public static void copyObject_test4() throws Exception {

// File should be copied as ETag set in copyConditions doesn't match object's
// ETag.
client.copyObject(bucketName, objectName, destBucketName, copyConditions);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, copyConditions);
client.getObject(destBucketName, objectName).close();

client.removeObject(bucketName, objectName);
Expand Down Expand Up @@ -2179,7 +2179,7 @@ public static void copyObject_test5() throws Exception {
matchingETagNone.setMatchETagNone(stat.etag());

try {
client.copyObject(bucketName, objectName, destBucketName, matchingETagNone);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, matchingETagNone);
} catch (ErrorResponseException e) {
// File should not be copied as ETag set in copyConditions matches object's
// ETag.
Expand Down Expand Up @@ -2228,7 +2228,7 @@ public static void copyObject_test6() throws Exception {
modifiedDateCondition.setModified(dateRepresentation);

// File should be copied as object was modified after the set date.
client.copyObject(bucketName, objectName, destBucketName, modifiedDateCondition);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, modifiedDateCondition);
client.getObject(destBucketName, objectName).close();

client.removeObject(bucketName, objectName);
Expand Down Expand Up @@ -2272,7 +2272,7 @@ public static void copyObject_test7() throws Exception {
invalidUnmodifiedCondition.setUnmodified(dateRepresentation);

try {
client.copyObject(bucketName, objectName, destBucketName, invalidUnmodifiedCondition);
client.copyObject(destBucketName, objectName, null, null, bucketName, null, null, invalidUnmodifiedCondition);
} catch (ErrorResponseException e) {
// File should not be copied as object was modified after date set in
// copyConditions.
Expand Down Expand Up @@ -2323,7 +2323,8 @@ public static void copyObject_test8() throws Exception {
Map<String, String> metadata = new HashMap<>();
metadata.put("Content-Type", customContentType);

client.copyObject(bucketName, objectName, destBucketName, objectName, copyConditions, metadata);
client.copyObject(destBucketName, objectName, metadata, null,
bucketName, objectName, null, copyConditions);

ObjectStat objectStat = client.statObject(destBucketName, objectName);
if (!customContentType.equals(objectStat.contentType())) {
Expand Down Expand Up @@ -2369,7 +2370,8 @@ public static void copyObject_test9() throws Exception {
CopyConditions copyConditions = new CopyConditions();
copyConditions.setReplaceMetadataDirective();

client.copyObject(bucketName, objectName, bucketName, objectName, copyConditions, new HashMap<String, String>());
client.copyObject(bucketName, objectName, new HashMap<String, String>(), null,
bucketName, objectName, null, copyConditions);
ObjectStat objectStat = client.statObject(bucketName, objectName);
if (objectStat.httpHeaders().containsKey("X-Amz-Meta-Test")) {
throw new Exception("expected user-defined metadata has been removed");
Expand Down Expand Up @@ -2422,7 +2424,7 @@ public static void copyObject_test10() throws Exception {
CopyConditions copyConditions = new CopyConditions();
copyConditions.setReplaceMetadataDirective();

client.copyObject(bucketName, objectName, sseSource, bucketName, objectName, copyConditions, sseTarget);
client.copyObject(bucketName, objectName, null, sseTarget, bucketName, objectName, sseSource, copyConditions);
ObjectStat objectStat = client.statObject(bucketName, objectName, sseTarget);

client.removeObject(bucketName, objectName);
Expand Down Expand Up @@ -2463,7 +2465,7 @@ public static void copyObject_test11() throws Exception {
CopyConditions copyConditions = new CopyConditions();
copyConditions.setReplaceMetadataDirective();

client.copyObject(bucketName, objectName, null, bucketName, objectName, copyConditions, sse);
client.copyObject(bucketName, objectName, null, sse, bucketName, objectName, null, copyConditions);
ObjectStat objectStat = client.statObject(bucketName, objectName);
if (objectStat.httpHeaders().containsKey("X-Amz-Meta-Test")) {
throw new Exception("expected user-defined metadata has been removed");
Expand Down Expand Up @@ -2515,7 +2517,7 @@ public static void copyObject_test12() throws Exception {
CopyConditions copyConditions = new CopyConditions();
copyConditions.setReplaceMetadataDirective();

client.copyObject(bucketName, objectName, null, bucketName, objectName, copyConditions, sse);
client.copyObject(bucketName, objectName, null, sse, bucketName, objectName, null, copyConditions);
ObjectStat objectStat = client.statObject(bucketName, objectName);
if (objectStat.httpHeaders().containsKey("X-Amz-Meta-Test")) {
throw new Exception("expected user-defined metadata has been removed");
Expand Down