@@ -1807,7 +1807,7 @@ public void copyObject(String bucketName, String objectName, String destBucketNa
18071807 NoResponseException , ErrorResponseException , InternalException , IOException , XmlPullParserException ,
18081808 InvalidArgumentException {
18091809
1810- copyObject (bucketName , objectName , destBucketName , null , null );
1810+ copyObject (bucketName , objectName , destBucketName , null , null , null );
18111811 }
18121812
18131813 /**
@@ -1842,7 +1842,7 @@ public void copyObject(String bucketName, String objectName, String destBucketNa
18421842 NoResponseException , ErrorResponseException , InternalException , IOException , XmlPullParserException ,
18431843 InvalidArgumentException {
18441844
1845- copyObject (bucketName , objectName , destBucketName , destObjectName , null );
1845+ copyObject (bucketName , objectName , destBucketName , destObjectName , null , null );
18461846 }
18471847
18481848 /**
@@ -1880,7 +1880,7 @@ public void copyObject(String bucketName, String objectName, String destBucketNa
18801880 NoResponseException , ErrorResponseException , InternalException , IOException , XmlPullParserException ,
18811881 InvalidArgumentException {
18821882
1883- copyObject (bucketName , objectName , destBucketName , null , copyConditions );
1883+ copyObject (bucketName , objectName , destBucketName , null , copyConditions , null );
18841884 }
18851885
18861886 /**
@@ -1921,6 +1921,51 @@ public void copyObject(String bucketName, String objectName, String destBucketNa
19211921 NoResponseException , ErrorResponseException , InternalException , IOException , XmlPullParserException ,
19221922 InvalidArgumentException {
19231923
1924+ copyObject (bucketName , objectName , destBucketName , destObjectName , copyConditions , null );
1925+ }
1926+
1927+ /**
1928+ * Copy a source object into a new object with the provided name in the provided bucket.
1929+ * optionally can take a key value CopyConditions as well for conditionally attempting
1930+ * copyObject.
1931+ *
1932+ * </p>
1933+ * <b>Example:</b><br>
1934+ *
1935+ * <pre>
1936+ * {@code minioClient.copyObject("my-bucketname", "my-objectname", "my-destbucketname",
1937+ * "my-destobjname", copyConditions, metadata);}
1938+ * </pre>
1939+ *
1940+ * @param bucketName
1941+ * Bucket name where the object to be copied exists.
1942+ * @param objectName
1943+ * Object name source to be copied.
1944+ * @param destBucketName
1945+ * Bucket name where the object will be copied to.
1946+ * @param destObjectName
1947+ * Object name to be created, if not provided uses source object name
1948+ * as destination object name.
1949+ * @param copyConditions
1950+ * CopyConditions object with collection of supported CopyObject conditions.
1951+ * @param metadata
1952+ * Additional metadata to set on the destination object when
1953+ * setMetadataDirective is set to 'REPLACE'.
1954+ *
1955+ * @throws InvalidBucketNameException
1956+ * upon an invalid bucket name, invalid object name.
1957+ * @throws NoSuchAlgorithmException
1958+ * upon requested algorithm was not found during signature calculation
1959+ * @throws InvalidKeyException
1960+ * upon an invalid access key or secret key
1961+ */
1962+ public void copyObject (String bucketName , String objectName , String destBucketName ,
1963+ String destObjectName , CopyConditions copyConditions ,
1964+ Map <String ,String > metadata )
1965+ throws InvalidKeyException , InvalidBucketNameException , NoSuchAlgorithmException , InsufficientDataException ,
1966+ NoResponseException , ErrorResponseException , InternalException , IOException , XmlPullParserException ,
1967+ InvalidArgumentException {
1968+
19241969 if (bucketName == null ) {
19251970 throw new InvalidArgumentException ("Source bucket name cannot be empty" );
19261971 }
@@ -1949,6 +1994,11 @@ public void copyObject(String bucketName, String objectName, String destBucketNa
19491994 headerMap .putAll (copyConditions .getConditions ());
19501995 }
19511996
1997+ // Set metadata on the destination of object.
1998+ if (metadata != null ) {
1999+ headerMap .putAll (metadata );
2000+ }
2001+
19522002 HttpResponse response = executePut (destBucketName , destObjectName , headerMap ,
19532003 null , "" , 0 );
19542004
0 commit comments