Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use GetObjectTagging
with a CLI
The following code examples show how to use GetObjectTagging
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- CLI
-
- Amazon CLI
-
To retrieve the tags attached to an object
The following get-object-tagging
example retrieves the values for the specified key from the specified object.
aws s3api get-object-tagging \
--bucket amzn-s3-demo-bucket
\
--key doc1.rtf
Output:
{
"TagSet": [
{
"Value": "confidential",
"Key": "designation"
}
]
}
The following get-object-tagging
example tries to retrieve the tag sets of the object doc2.rtf
, which has no tags.
aws s3api get-object-tagging \
--bucket amzn-s3-demo-bucket
\
--key doc2.rtf
Output:
{
"TagSet": []
}
The following get-object-tagging
example retrieves the tag sets of the object doc3.rtf
, which has multiple tags.
aws s3api get-object-tagging \
--bucket amzn-s3-demo-bucket
\
--key doc3.rtf
Output:
{
"TagSet": [
{
"Value": "confidential",
"Key": "designation"
},
{
"Value": "finance",
"Key": "department"
},
{
"Value": "payroll",
"Key": "team"
}
]
}
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: The sample returns the tags associated with the object present on the given S3 bucket.
Get-S3ObjectTagSet -Key 'testfile.txt' -BucketName 'amzn-s3-demo-bucket'
Output:
Key Value
--- -----
test value
- Tools for PowerShell V5
-
Example 1: The sample returns the tags associated with the object present on the given S3 bucket.
Get-S3ObjectTagSet -Key 'testfile.txt' -BucketName 'amzn-s3-demo-bucket'
Output:
Key Value
--- -----
test value
For a complete list of Amazon SDK developer guides and code examples, see
Developing with Amazon S3 using the Amazon SDKs.
This topic also includes information about getting started and details about previous SDK versions.