Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Objects: get

Retrieves objects or their associated metadata. Try it now or see an example .

The default alt parameter for this method is media , unlike the other Objects methods, which implies that you will download the actual media content rather than the metadata. To retrieve the metadata for the object instead, set the alt parameter to json : " ?alt=json ".

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.

Request

HTTP request

GET https://www.googleapis.com/storage/v1beta1/b/bucket/o/object

Parameters

Parameter name Value Description
Required parameters
bucket string Name of the bucket in which the object resides.
object string Name of the object.
Optional parameters
projection string Set of properties to return. Defaults to no_acl .

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

Request body

Do not supply a request body with this method.

Response

If successful, this method returns an object resource in the response body.

Examples

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).

Java

Uses the Java client library

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

if (getMetadata == true) {
  getObject.setAlt("json");  // Temporary workaround.
  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.
  // NOTE: As of right now, this will not retry on retryable failure.
  // http://code.google.com/p/google-api-java-client/issues/detail?id=579
  getObject.getMediaHttpDownloader().setDirectDownloadEnabled(true);
  getObject.download(out);
}

Ruby

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

Try it!

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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.