AWS S3 CopyObject Version
amazon-s3, amazon-web-services, php
Solution
I have found an answer thanks to the AWS Discussion forum. The right parameters setup is
$param = array(
'Bucket' => $this->bucket,
'CopySource' => urlencode($this->bucket . $this->delimiter . $source_key) . '?versionId=' . $source_version_id,
'Key' => $dest_key
);
Problem
I'm trying to implement "restore" object by creating a copy of an older object version. I am using AWS PHP SDK 2, method copyObject, but I cannot find a way to specify versionID of the source object. AWS REST API documentation (ref) mentions To copy a different version, use the versionId subresource. but it is not mentioned in the SDK docs. I tried to add the versionID to the "CopySource" attribute, SDK docs say that it is The name of the source bucket and key name of the source object, separated by a slash (/) but it did not work. ``` $param = array( 'Bucket' => $this->bucket, 'CopySource' => urlencode($this->bucket . $this->delimiter . $source_key . $this->delimiter . $source_version_id), 'Key' => $dest_key ); $result = $this->s3Client->copyObject($param); ``` Question How can I specify the versionID of the source object?