Listing the Versions of an Object

You can list the current and the previous versions of an object you uploaded or copied into your bucket. This action also returns information about the owner of the object, and the date and time of each version.

You can download any version of an object. The versions are only available if you enabled the bucket versioning. You can still download any version of an object after disabling the bucket versioning. For more information, see Enabling or Disabling Bucket Versioning.

If you remove an object without specifying its version ID when the bucket versioning is enabled, a delete marker is created. For more information, see Removing Objects from a Bucket.

Listing the Versions of an Object Using AWS CLI

Before you begin: Install and configure AWS CLI and set up your profile. For more information, see Installing and Configuring AWS CLI.

To list the different versions of an object, use the list-object-versions command following this syntax:

Request sample
$ aws s3api list-object-versions \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    [--key NOT_SPECIFIED] \
    --prefix PREFIX/OBJECT \
    [--delimiter NOT_SPECIFIED] \
    --endpoint https://oos.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of your bucket.

  • (optional) key: The name of the object.

  • (optional) prefix: A letter or a string of characters to filter your objects. It displays the objects that begin with the letter or the characters you specify.

  • (optional) delimiter: A letter to filter your objects. It excludes the objects that begin or contain the letter you specify.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The list-object-versions command returns the following elements:

  • Name: The name of the bucket.

  • Versions: Information about the versions of an object. This element contains the following information:

    • LastModified: The date and time at which the object was uploaded or copied.

    • VersionId: The ID of a previous or of the current version of the object.

    • ETag: The ETag of the object.

    • StorageClass: The storage class of the object (always STANDARD).

    • Key: The name of the object.

    • Owner: Information about the owner of the object. This element contains the following information:

      • DisplayName: The OUTSCALE account ID of the owner of the object.

      • ID: The S3 user ID of the owner of the object.

    • IsLatest: Whether the version of the object is the current or not (true | false).

    • Size: The size of the object, in bytes.

  • Prefix: The prefix you specified.

  • MaxKeys: The number of keys returned by the command (by default, 1000).

  • Delimiter: The delimiter you specified.

  • KeyMarker: The key you specified.

  • DeleteMarkers: Information about the delete markers. This element contains the following information:

    • Owner: Information about the owner of the object. This element contains the following information:

      • DisplayName: The OUTSCALE account ID of the owner of the object.

      • ID: The S3 user ID of the owner of the object.

    • IsLatest: Whether the version of the object is the latest or not (true | false).

    • Size: The size of the object, in bytes.

    • Key: The key of the object.

    • LastModified: The date and time at which the object was uploaded or copied.

  • IsTruncated: If the result is truncated (true | false).

  • CommonPrefixes: Information about the common prefixes. This element contains the following information:

    • Prefix: The string of characters from your prefix to your delimiter. For more information, see About OOS > Objects.

Result Sample
{
    "Name": "BUCKET",
    "Versions": [
        {
            "LastModified": "2017-05-02T13:59:23.714Z",
            "VersionId": "7395H3JvbAV16lq1tBbxUbtaJ7K4PCP",
            "ETag": "\"93494ed0663d6a689b5e1f90d9e29d41\"",
            "StorageClass": "STANDARD",
            "Key": "PREFIX/OBJECT_1",
            "Owner": {
                "DisplayName": "ACCOUNT_ID",
                "ID": "USER_ID"
            },
            "IsLatest": true,
            "Size": 42
        },
        {
            "LastModified": "2017-05-02T13:59:33.643Z",
            "VersionId": "hYamlBeJKxeixLh5SOG6li7FhdYeqhv",
            "ETag": "\"a9e872119bfa18db39ed9207c3c5b81f\"",
            "StorageClass": "STANDARD",
            "Key": "PREFIX/OBJECT_2",
            "Owner": {
                "DisplayName": "ACCOUNT_ID",
                "ID": "USER_ID"
            },
            "IsLatest": true,
            "Size": 20
        },
        {
            "LastModified": "2017-05-02T13:59:42.032Z",
            "VersionId": "EB-pqyVSnVrbF2uv0.Mm1kS7OOvBZz5",
            "ETag": "\"727479ef7cedf30c03459bec7d87b0f0\"",
            "StorageClass": "STANDARD",
            "Key": "PREFIX/OBJECT_3",
            "Owner": {
                "DisplayName": "ACCOUNT_ID",
                "ID": "USER_ID"
            },
            "IsLatest": false,
            "Size": 5
        }
    ],
    "Prefix": "PREFIX/OBJECT",
    "MaxKeys": 1000,
    "Delimiter": "/",
    "KeyMarker": "/",
    "DeleteMarkers": [
        {
            "Owner": {
                "DisplayName": "ACCOUNT_ID",
                "ID": "USER_ID"
            },
            "IsLatest": true,
            "VersionId": "gO.3oj9gKafUhoMzP77RDU-NYg4EkG7",
            "Key": "PREFIX/OBJECT_4",
            "LastModified": "2017-05-02T14:09:03.047Z"
        }
    ],
    "IsTruncated": false,
    "CommonPrefixes": [
        {
            "Prefix": "PREFIX/OBJECT"
        }
    ]
}

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.