Object metadata operations for the Google Cloud Storage JSON API.
Responses are the decoded JSON
Object resource
as a map with string keys. For transferring object bytes, see
GcpGcs.Upload and GcpGcs.Download.
These functions are exposed through the top-level GcpGcs module.
Summary
Functions
Concatenates up to 32 source objects in the same bucket into dest_object.
Copies an object. Suitable for same-location copies; for large or
cross-location copies prefer rewrite/5.
Deletes an object. Returns :ok on success.
Gets an object's metadata (not its contents).
Lists objects in a bucket.
Moves (renames) an object within a bucket. Requires a bucket with hierarchical namespace enabled.
Rewrites (copies) an object, following GCS rewrite tokens until the operation
completes. Handles large and cross-location/cross-storage-class copies that a
single copy/5 cannot.
Patches an object's metadata with attrs (a map of Object resource fields,
e.g. %{"contentType" => "text/plain", "metadata" => %{"key" => "value"}}).
Functions
@spec compose(String.t(), String.t(), [String.t() | map()], keyword()) :: {:ok, map()} | {:error, GcpGcs.Error.t()}
Concatenates up to 32 source objects in the same bucket into dest_object.
sources is a list of object names (strings) or maps with a "name" key.
Options
:attrs— destination Object resource fields (e.g.%{"contentType" => ...}):timeout— request timeout in ms
@spec copy(String.t(), String.t(), String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, GcpGcs.Error.t()}
Copies an object. Suitable for same-location copies; for large or
cross-location copies prefer rewrite/5.
Options
:attrs— destination Object resource fields to set:timeout— request timeout in ms
@spec delete(String.t(), String.t(), keyword()) :: :ok | {:error, GcpGcs.Error.t()}
Deletes an object. Returns :ok on success.
@spec get(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, GcpGcs.Error.t()}
Gets an object's metadata (not its contents).
Options
:generation— a specific object generation:timeout— request timeout in ms
@spec list( String.t(), keyword() ) :: {:ok, %{items: list(), prefixes: list(), next_page_token: String.t() | nil}} | {:error, GcpGcs.Error.t()}
Lists objects in a bucket.
Options
:prefix— filter to names starting with this prefix:delimiter— collapse names with this delimiter into:prefixes(use"/"to list a single "directory" level):page_size— maximum results per page (maps tomaxResults):page_token— pagination token:start_offset/:end_offset— lexicographic range filters:versions—trueto include non-current object versions
Returns {:ok, %{items: [...], prefixes: [...], next_page_token: token}}.
@spec move(String.t(), String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, GcpGcs.Error.t()}
Moves (renames) an object within a bucket. Requires a bucket with hierarchical namespace enabled.
@spec rewrite(String.t(), String.t(), String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, GcpGcs.Error.t()}
Rewrites (copies) an object, following GCS rewrite tokens until the operation
completes. Handles large and cross-location/cross-storage-class copies that a
single copy/5 cannot.
Options
:attrs— destination Object resource fields to set:max_bytes_per_call—maxBytesRewrittenPerCall(must be a multiple of 1 MiB):timeout— request timeout per underlying call, in ms
Returns {:ok, object_resource} for the finished object.
Patches an object's metadata with attrs (a map of Object resource fields,
e.g. %{"contentType" => "text/plain", "metadata" => %{"key" => "value"}}).