這是一個兩步過程。您將不得不通過此api調用獲取所有版本的列表。
http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#listobjectversions
$result = $client->listObjectVersions([
'Bucket' => '<string>', // REQUIRED
]);
它返回
[
'CommonPrefixes' => [
[
'Prefix' => '<string>',
],
// ...
],
'DeleteMarkers' => [
[
'IsLatest' => true || false,
'Key' => '<string>',
'LastModified' => <DateTime>,
'Owner' => [
'DisplayName' => '<string>',
'ID' => '<string>',
],
'VersionId' => '<string>',
],
// ...
],
'Delimiter' => '<string>',
'EncodingType' => 'url',
'IsTruncated' => true || false,
'KeyMarker' => '<string>',
'MaxKeys' => <integer>,
'Name' => '<string>',
'NextKeyMarker' => '<string>',
'NextVersionIdMarker' => '<string>',
'Prefix' => '<string>',
'VersionIdMarker' => '<string>',
'Versions' => [
[
'ETag' => '<string>',
'IsLatest' => true || false,
'Key' => '<string>',
'LastModified' => <DateTime>,
'Owner' => [
'DisplayName' => '<string>',
'ID' => '<string>',
],
'Size' => <integer>,
'StorageClass' => 'STANDARD',
'VersionId' => '<string>',
],
// ...
],
]
然後設置VERSIONID參數GetObject這個API調用
$result = $client->getObject([
'Bucket' => '<string>', // REQUIRED
'VersionId' => '<string>',
]);`
http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#getobject