This page shows you how to read object data from your Cloud Storage buckets directly into application memory or interactively in your web browser or command-line terminal. Reading objects into memory or interactively is recommended when you want to stream, inspect, or process data in a way that avoids the CPU, disk I/O, and latency overhead associated with writing files into a persistent local file system.
For instructions on downloading objects into persistent or local storage, see Download objects. For a conceptual overview of object reads and downloads, see Object reads and downloads.
Required roles
To get the permissions that you need to read object data, ask your administrator to grant you the following IAM roles:
- Storage Object Viewer (
roles/storage.objectViewer) on the bucket - Storage Admin (
roles/storage.admin) on the project (only required for reading object data by using the Google Cloud console)
For more information about granting roles, see Manage access to projects, folders, and organizations.
The Storage Object Viewer (roles/storage.objectViewer) role contains the
storage.objects.get permission, which is required for reading objects. The
Storage Admin (roles/storage.admin) role contains the storage.buckets.list
and storage.buckets.get permissions, in addition to the storage.objects.get
permission. These permissions are required for listing the buckets in a project
and viewing information about the buckets. The Storage Admin
(roles/storage.admin) role that includes these permissions is only required
when you want to read objects interactively using the Google Cloud console.
You might also be able to get these permissions with custom roles or other predefined roles.
For instructions on granting roles on buckets, see Set and manage IAM policies on buckets.
Read objects programmatically into memory
This section describes how to read object data by streaming the object bytes directly into application memory.
Client libraries
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++