The Google Cloud Storage (GCS) C++ Client library offers types and functions access GCS from C++ applications. It offers full access to the GCS API, including operations to list, read, write, and delete GCS objects and buckets. The library also provides functions to modify the IAM permissions on buckets, read and modify the metadata associated with objects and buckets, configure encryption keys, configure notifications via Cloud Pub/Sub, and change the access control list of object or buckets.
Quickstart
The following "Hello World" program should give you a taste of this library. This program is also used to illustrate how to incorporate the library into your project.
#include "google/cloud/storage/client.h"
#include <iostream>
#include <string>
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Missing bucket name.\n";
std::cerr << "Usage: quickstart <bucket-name>\n";
return 1;
}
std::string const bucket_name = argv[1];
// Create a client to communicate with Google Cloud Storage. This client
// uses the default configuration for authentication and project id.
auto client = google::cloud::storage::Client();
auto writer = client.WriteObject(bucket_name, "quickstart.txt");
writer << "Hello World!";
writer.Close();
if (!writer.metadata()) {
std::cerr << "Error creating object: " << writer.metadata().status()
<< "\n";
return 1;
}
std::cout << "Successfully created object: " << *writer.metadata() << "\n";
auto reader = client.ReadObject(bucket_name, "quickstart.txt");
if (!reader) {
std::cerr << "Error reading object: " << reader.status() << "\n";
return 1;
}
std::string contents{std::istreambuf_iterator<char>{reader}, {}};
std::cout << contents << "\n";
return 0;
}
Error Handling to learn how the library reports run-time errors.
Environment Variables for environment variables affecting the library. Some of these environment variables enable logging to the console. This can be an effective approach to diagnose runtime problems.
The Setting up your development environment guide describes how to set up a C++ development environment in various platforms, including the Google Cloud C++ client libraries.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThe Google Cloud Storage C++ Client library provides comprehensive access to the GCS API for C++ applications, enabling operations like listing, reading, writing, and deleting objects and buckets.\u003c/p\u003e\n"],["\u003cp\u003eThe library facilitates management of IAM permissions, metadata, encryption keys, Cloud Pub/Sub notifications, and access control lists for GCS buckets and objects.\u003c/p\u003e\n"],["\u003cp\u003eThe provided quickstart demonstrates a basic "Hello World" program using the library to create and read an object in a specified bucket.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version is 2.37.0-rc, and there are links to documentation for past versions, including version 2.11.0 up to the present, to help users access the appropriate information for their used version.\u003c/p\u003e\n"],["\u003cp\u003eVarious resources are available for error handling, setting environment variables, overriding default endpoints, authentication, retry policies, writing tests with a mock client, and setting up the C++ development environment.\u003c/p\u003e\n"]]],[],null,["Version latestkeyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/storage/latest)\n- [2.41.0](/cpp/docs/reference/storage/2.41.0)\n- [2.40.0](/cpp/docs/reference/storage/2.40.0)\n- [2.39.0](/cpp/docs/reference/storage/2.39.0)\n- [2.38.0](/cpp/docs/reference/storage/2.38.0)\n- [2.37.0](/cpp/docs/reference/storage/2.37.0)\n- [2.36.0](/cpp/docs/reference/storage/2.36.0)\n- [2.35.0](/cpp/docs/reference/storage/2.35.0)\n- [2.34.0](/cpp/docs/reference/storage/2.34.0)\n- [2.33.0](/cpp/docs/reference/storage/2.33.0)\n- [2.32.0](/cpp/docs/reference/storage/2.32.0)\n- [2.31.0](/cpp/docs/reference/storage/2.31.0)\n- [2.30.0](/cpp/docs/reference/storage/2.30.0)\n- [2.29.0](/cpp/docs/reference/storage/2.29.0)\n- [2.28.0](/cpp/docs/reference/storage/2.28.0)\n- [2.27.0](/cpp/docs/reference/storage/2.27.0)\n- [2.26.0](/cpp/docs/reference/storage/2.26.0)\n- [2.25.1](/cpp/docs/reference/storage/2.25.1)\n- [2.24.0](/cpp/docs/reference/storage/2.24.0)\n- [2.23.0](/cpp/docs/reference/storage/2.23.0)\n- [2.22.1](/cpp/docs/reference/storage/2.22.1)\n- [2.21.0](/cpp/docs/reference/storage/2.21.0)\n- [2.20.0](/cpp/docs/reference/storage/2.20.0)\n- [2.19.0](/cpp/docs/reference/storage/2.19.0)\n- [2.18.0](/cpp/docs/reference/storage/2.18.0)\n- [2.17.0](/cpp/docs/reference/storage/2.17.0)\n- [2.16.0](/cpp/docs/reference/storage/2.16.0)\n- [2.15.1](/cpp/docs/reference/storage/2.15.1)\n- [2.14.0](/cpp/docs/reference/storage/2.14.0)\n- [2.13.0](/cpp/docs/reference/storage/2.13.0)\n- [2.12.0](/cpp/docs/reference/storage/2.12.0)\n- [2.11.0](/cpp/docs/reference/storage/2.11.0) \n\nGoogle Cloud Storage C++ Client Library\n=======================================\n\nThe Google Cloud Storage (GCS) C++ Client library offers types and functions access GCS from C++ applications. It offers full access to the GCS API, including operations to list, read, write, and delete [GCS objects](https://cloud.google.com/storage/docs/key-terms#objects) and [buckets](https://cloud.google.com/storage/docs/key-terms#buckets). The library also provides functions to modify the IAM permissions on buckets, read and modify the metadata associated with objects and buckets, configure encryption keys, configure notifications via Cloud Pub/Sub, and change the access control list of object or buckets.\n\n### Quickstart\n\nThe following \"Hello World\" program should give you a taste of this library. This program is also used to illustrate how to incorporate the library into your project. \n\n #include \"google/cloud/storage/client.h\"\n #include \u003ciostream\u003e\n #include \u003cstring\u003e\n\n int main(int argc, char* argv[]) {\n if (argc != 2) {\n std::cerr \u003c\u003c \"Missing bucket name.\\n\";\n std::cerr \u003c\u003c \"Usage: quickstart \u003cbucket-name\u003e\\n\";\n return 1;\n }\n std::string const bucket_name = argv[1];\n\n // Create a client to communicate with Google Cloud Storage. This client\n // uses the default configuration for authentication and project id.\n auto client = google::cloud::storage::Client();\n\n auto writer = client.WriteObject(bucket_name, \"quickstart.txt\");\n writer \u003c\u003c \"Hello World!\";\n writer.Close();\n if (!writer.metadata()) {\n std::cerr \u003c\u003c \"Error creating object: \" \u003c\u003c writer.metadata().status()\n \u003c\u003c \"\\n\";\n return 1;\n }\n std::cout \u003c\u003c \"Successfully created object: \" \u003c\u003c *writer.metadata() \u003c\u003c \"\\n\";\n\n auto reader = client.ReadObject(bucket_name, \"quickstart.txt\");\n if (!reader) {\n std::cerr \u003c\u003c \"Error reading object: \" \u003c\u003c reader.status() \u003c\u003c \"\\n\";\n return 1;\n }\n\n std::string contents{std::istreambuf_iterator\u003cchar\u003e{reader}, {}};\n std::cout \u003c\u003c contents \u003c\u003c \"\\n\";\n\n return 0;\n }\n\n### More Information\n\n- [ReadObject()](/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1Client#classgoogle_1_1cloud_1_1storage_1_1Client_1a8b0575846b68475f6b1f7ef950b49323) - the function to read object data.\n- [WriteObject()](/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1Client#classgoogle_1_1cloud_1_1storage_1_1Client_1a8918b5f338d91607b06d5107965ed35e) - the function to write objects.\n- [InsertObject()](/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1Client#classgoogle_1_1cloud_1_1storage_1_1Client_1a6056ae55399688c7317693775d3609ad) - the function to write small objects.\n- [Error Handling](/cpp/docs/reference/storage/latest/storage-error) to learn how the library reports run-time errors.\n- [Environment Variables](/cpp/docs/reference/storage/latest/storage-env) for environment variables affecting the library. Some of these environment variables enable logging to the console. This can be an effective approach to diagnose runtime problems.\n- [Override the Default Endpoint](/cpp/docs/reference/storage/latest/storage-endpoint-example)\n- [Override the authentication configuration](/cpp/docs/reference/storage/latest/storage-auth-example)\n- [Override the default retry policies](/cpp/docs/reference/storage/latest/storage-retry-examples)\n- [Writing Tests with a Mock Client](/cpp/docs/reference/storage/latest/storage-mocking) shows how to write tests mocking the [Client](/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1Client) class\n- The [Setting up your development environment](https://cloud.google.com/cpp/docs/setup) guide describes how to set up a C++ development environment in various platforms, including the Google Cloud C++ client libraries."]]