Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
This page describes how to change the storage class of objects within a bucket through rewriting the object.
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 permissions section:
Required permissionsstorage.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 Set and manage IAM policies on buckets.
Change an object's storage classComplete the following steps to change an object's storage class:
ConsoleIndividual object storage classes cannot be set through the Google Cloud console. Instead, use the Google Cloud CLI.
Command lineUse 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
.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.
GoFor 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.
JavaFor 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.jsFor 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.
PHPFor 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.
PythonFor 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.
RubyFor 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.
REST APIs JSON API Caution: ACLs that you want to retain from the original object must be included in the object resource that you provide in the request body.Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization
header.
Create a JSON file that contains the following information:
{ "storageClass": "STORAGE_CLASS" }
Where:
STORAGE_CLASS
is the new storage class for your object. For example, nearline
.Use cURL
to call the JSON API with a POST
Object, request:
curl -X POST --data-binary @JSON_FILE_NAME \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o/OBJECT_NAME/rewriteTo/b/BUCKET_NAME/o/OBJECT_NAME"
Where:
JSON_FILE_NAME
is the path for the JSON file that you created in Step 2.BUCKET_NAME
is the name of the bucket containing the original object. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the object. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization
header.
Use cURL
to call the XML API with a PUT
Object request:
curl -X PUT --data-binary @OBJECT \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: OBJECT_CONTENT_TYPE" \ -H "x-goog-storage-class: STORAGE_CLASS" \ "https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME"
Where:
OBJECT
is the local path to the object whose storage class you want to change (you must re-upload the object when changing storage class with the XML API). For example, Desktop/dog.png
.OBJECT_CONTENT_TYPE
is the content type of the object. For example, image/png
.STORAGE_CLASS
is the new storage class for your object. For example, nearline
.BUCKET_NAME
is the name of the bucket containing the object you are rewriting. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the object you are rewriting. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-02 UTC.
[[["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-10-02 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5