Represents the metadata for a Google Cloud Storage Object.
Note that all modifiers just change the local representation of the Object's metadata. Applications should use Client::PatchObject(), or a similar operation, to actually modify the metadata stored by GCS.
In buckets with object versioning enabled, each object may have multiple generations. Each generation data (the object contents) is immutable, but the metadata associated with each generation can be changed.
Returns
Type
Description
std::int64_t
set_generation(std::int64_t)
Parameter
Name
Description
v
std::int64_t
Returns
Type
Description
ObjectMetadata &
id() const
The id attribute (the object name)
Returns
Type
Description
std::string const &
set_id(std::string)
Parameter
Name
Description
v
std::string
Returns
Type
Description
ObjectMetadata &
kind() const
The kind attribute, that is, storage#object.
Returns
Type
Description
std::string const &
set_kind(std::string)
Parameter
Name
Description
v
std::string
Returns
Type
Description
ObjectMetadata &
kms_key_name() const
The name of the KMS (Key Management Service) key used in this object.
This is empty for objects not using CMEK (Customer Managed Encryption Keys).
Returns
Type
Description
std::string const &
set_kms_key_name(std::string)
Parameter
Name
Description
v
std::string
Returns
Type
Description
ObjectMetadata &
md5_hash() const
The MD5 hash of the object contents. Can be empty.
Returns
Type
Description
std::string const &
set_md5_hash(std::string)
Parameter
Name
Description
v
std::string
Returns
Type
Description
ObjectMetadata &
media_link() const
The HTTPS link to access the object contents.
Returns
Type
Description
std::string const &
set_media_link(std::string)
Parameter
Name
Description
v
std::string
Returns
Type
Description
ObjectMetadata &
metageneration() const
The generation of the object metadata.
Returns
Type
Description
std::int64_t
set_metageneration(std::int64_t)
Parameter
Name
Description
v
std::int64_t
Returns
Type
Description
ObjectMetadata &
name() const
The object name, including bucket and generation.
Returns
Type
Description
std::string const &
set_name(std::string)
Parameter
Name
Description
v
std::string
Returns
Type
Description
ObjectMetadata &
has_owner() const
Returns true if the object has an owner attribute.
Returns
Type
Description
bool
owner() const
The object's owner attribute.
It is undefined behavior to call this member function if has_owner()== false.
Returns
Type
Description
Owner const &
set_owner(Owner)
Parameter
Name
Description
v
Owner
Returns
Type
Description
ObjectMetadata &
reset_owner()
Returns
Type
Description
ObjectMetadata &
retention_expiration_time() const
The retention expiration time, or the system clock's epoch, if not set.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-02 UTC."],[[["This documentation outlines the `ObjectMetadata` class in Google Cloud Storage, which represents metadata associated with a GCS object."],["The `ObjectMetadata` class provides functions to access, modify, and manage various metadata attributes like `cacheControl`, `contentType`, `owner`, `storageClass`, and custom metadata entries."],["The class supports versioning, allowing multiple generations of an object to exist, with each generation having its own metadata, that can be altered independently."],["The `ObjectMetadata` class also includes methods to handle access control lists, encryption keys, checksums, and timestamps related to object creation, deletion, and updates."],["The `Client::PatchObject()` function is recommended to modify metadata in the Google Cloud Storage, whereas the class methods presented here will only modify the local object metadata representation."]]],[]]