This page describes how to change the storage class of objects within a bucket through rewriting the object.
- To learn how to change object storage classes without rewriting an object, see the Object Lifecycle Management feature.
- To learn how Cloud Storage can automatically manage your object's storage classes, see the Autoclass feature .
Required roles
In order to get the required permissions for changing the storage class of
an object through rewriting the object, ask your administrator to grant you the
Storage Object User ( roles/storage.objectUser
) role on the bucket.
This role contains the permissions required to change the storage class of an object. To see the exact permissions that are required, expand the Required permissionssection:
Required permissions
-
storage.objects.create
-
storage.objects.delete
-
storage.objects.get
-
storage.objects.list
You might also be able to get these permissions with other predefined roles or custom roles .
For instructions on granting roles on buckets, see Use IAM with buckets .
Change an object's storage class
Complete the following steps to change an object's storage class:
Console
Individual object storage classes cannot be set through the Google Cloud console . Instead, use the Google Cloud CLI.
Command line
Use the gcloud storage objects update
command with the --storage-class
flag. For example:
gcloud storage objects update gs:// BUCKET_NAME / OBJECT_NAME --storage-class= STORAGE_CLASS
Where:
-
BUCKET_NAME
is the name of the bucket containing the object whose class you want to change. For example,my-bucket
. -
OBJECT_NAME
is the name of the object whose class you want to change. For example,pets/dog.png
. -
STORAGE_CLASS
is the new storage class for your object. For example,nearline
.
Client libraries
C++
For more information, see the Cloud Storage C++ API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
C#
For more information, see the Cloud Storage C# API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Go
For more information, see the Cloud Storage Go API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Java
For more information, see the Cloud Storage Java API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Node.js
For more information, see the Cloud Storage Node.js API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
PHP
For more information, see the Cloud Storage PHP API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Python
For more information, see the Cloud Storage Python API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Ruby
For more information, see the Cloud Storage Ruby API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .