Google Cloud Platform
Cloud Storage

Objects: get

Retrieves an object or its metadata. Try it now or see an example.

The authenticated user must have READER permissions on the object. To retrieve the acl property, the authenticated user must have OWNER permissions on the object.


HTTP request



Parameter name Value Description
Path parameters
bucket string Name of the bucket in which the object resides.
object string Name of the object. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.
Optional query parameters
generation long If present, selects a specific revision of this object (as opposed to the latest version, the default).
ifGenerationMatch long Makes the operation conditional on whether the object's generation matches the given value.
ifGenerationNotMatch long Makes the operation conditional on whether the object's generation does not match the given value.
ifMetagenerationMatch long Makes the operation conditional on whether the object's current metageneration matches the given value.
ifMetagenerationNotMatch long Makes the operation conditional on whether the object's current metageneration does not match the given value.
projection string Set of properties to return. Defaults to noAcl.

Acceptable values are:
  • "full": Include all properties.
  • "noAcl": Omit the acl property.

Request body

Do not supply a request body with this method.


By default, this responds with an object resource in the response body. If you provide the URL parameter alt=media, then it will respond with the object data in the response body.


Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).


Uses the Java client library.

Storage.Objects.Get getObject = storage.objects().get("mybucket", "myobject");

if (getMetadata == true) {
  StorageObject object = getObject.execute();
} else {
  // Downloading data.
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // If you're not in AppEngine, download the whole thing in one request, if possible.


Uses the Python client library.

import io

from apiclient.http import MediaIoBaseDownload

# Get Metadata
req = client.objects().get(
        fields='bucket,name,metadata(my-key)',    # optional
        generation=generation)                    # optional
resp = req.execute()
print json.dumps(resp, indent=2)

# Get Payload Data
req = client.objects().get_media(
        generation=generation)    # optional
# The BytesIO object may be replaced with any io.Base instance.
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, req, chunksize=1024*1024)
done = False
while not done:
    status, done = downloader.next_chunk()
    if status:
        print 'Download %d%%.' % int(status.progress() * 100)
    print 'Download Complete!'
print fh.getvalue()


Uses the Ruby client library.

# Get a specific object from a bucket
bucket_get_result = client.execute(
  api_method: storage.objects.get,
  parameters: {bucket: BUCKET, object: OBJECT}
puts "Contents of #{OBJECT} in #{BUCKET}: "
puts bucket_get_result.body


Uses the Go client library.

// Get an object from a bucket.
bucketName := "BUCKET_NAME"
result, err := service.Objects.Get(bucketName, "OBJECT_NAME").Do()
fmt.Printf("The media download link for %v/%v is %v.\n",
	bucketName, result.Name, result.MediaLink)

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.