- 2.60.0 (latest)
- 2.59.0
- 2.58.1
- 2.57.0
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.3
- 2.52.3
- 2.50.0
- 2.49.0
- 2.48.2
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.1
- 2.43.2
- 2.42.0
- 2.41.0
- 2.40.1
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.1
- 2.34.0
- 2.33.0
- 2.32.1
- 2.30.1
- 2.29.1
- 2.28.0
- 2.27.1
- 2.24.0
- 2.23.0
- 2.22.6
- 2.21.0
- 2.20.2
- 2.19.0
- 2.18.0
- 2.17.2
- 2.16.0
- 2.15.1
- 2.14.0
- 2.13.1
- 2.12.0
- 2.11.3
- 2.10.0
- 2.9.3
- 2.8.1
- 2.7.1
- 2.6.1
- 2.5.1
- 2.4.5
- 2.3.0
- 2.2.3
- 2.1.10
A client for Cloud Storage - Unified object storage.
Here's a simple usage example the Java Storage client. This example shows how to create a Storage object.
Storage storage = StorageOptions.getDefaultInstance().getService();
BlobId blobId = BlobId.of("bucket", "blob_name");
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
Blob blob = storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
This second example shows how to update an object's content if the object exists.
Storage storage = StorageOptions.getDefaultInstance().getService();
BlobId blobId = BlobId.of("bucket", "blob_name");
Blob blob = storage.get(blobId);
if (blob != null) {
byte[] prevContent = blob.getContent();
System.out.println(new String(prevContent, UTF_8));
WritableByteChannel channel = blob.writer();
channel.write(ByteBuffer.wrap("Updated content".getBytes(UTF_8)));
channel.close();
}
For more detailed code examples, see the sample library.
When using google-cloud from outside of App/Compute Engine, you have to specify a project ID and provide credentials.
Operations in this library are generally thread safe, except for the use of BlobReadChannel and BlobWriteChannel. See Also: Google Cloud Storage
Classes
Acl
Access Control List for buckets or blobs. See Also: About Access Control Lists
Acl.Builder
Builder for Acl objects.
Acl.Domain
Class for ACL Domain entities.
Acl.Entity
Base class for Access Control List entities.
Acl.Group
Class for ACL Group entities.
Acl.Project
Class for ACL Project entities.
Acl.Project.ProjectRole
Acl.RawEntity
Acl.Role
Acl.User
Class for ACL User entities.
Blob
An object in Google Cloud Storage. A Blob object includes the BlobId instance,
the set of properties inherited from the BlobInfo class and the Storage instance.
The class provides methods to perform operations on the object. Reading a property value does not
issue any RPC calls. The object content is not stored within the Blob instance.
Operations that access the content issue one or multiple RPC calls, depending on the content
size.
Objects of this class are immutable. Operations that modify the blob like #update and
#copyTo return a new object. Any changes to the object in Google Cloud Storage made after
creation of the Blob are not visible in the Blob. To get a Blob object
with the most recent information use #reload.
Example of getting the content of the object in Google Cloud Storage:
BlobId blobId = BlobId.of(bucketName, blobName);
Blob blob = storage.get(blobId);
long size = blob.getSize(); // no RPC call is required
byte[] content = blob.getContent(); // one or multiple RPC calls will be issued
Blob.BlobSourceOption
Class for specifying blob source options when Blob methods are used.
Blob.Builder
Builder for Blob.
BlobId
Google Storage Object identifier. A BlobId object includes the name of the containing
bucket, the blob's name and possibly the blob's generation. If #getGeneration() is
null the identifier refers to the latest blob's generation.
BlobInfo
Information about an object in Google Cloud Storage. A BlobInfo object includes the
BlobId instance and the set of properties, such as the blob's access control
configuration, user provided metadata, the CRC32C checksum, etc. Instances of this class are used
to create a new object in Google Cloud Storage or update the properties of an existing object. To
deal with existing Storage objects the API includes the Blob class which extends
BlobInfo and declares methods to perform operations on the object. Neither BlobInfo nor
Blob instances keep the object content, just the object properties.
Example of usage BlobInfo to create an object in Google Cloud Storage:
BlobId blobId = BlobId.of(bucketName, blobName);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
Blob blob = storage.create(blobInfo, "Hello, world".getBytes(StandardCharsets.UTF_8));
See Also: Concepts and Terminology
BlobInfo.Builder
Builder for BlobInfo.
BlobInfo.CustomerEncryption
Objects of this class hold information on the customer-supplied encryption key, if the blob is encrypted using such a key.
BlobInfo.ImmutableEmptyMap<K,V>
This class is meant for internal use only. Users are discouraged from using this class.
Bucket
A Google cloud storage bucket.
Objects of this class are immutable. Operations that modify the bucket like #update
return a new object. To get a Bucket object with the most recent information use #reload. Bucket adds a layer of service-related functionality over BucketInfo.
Bucket.BlobTargetOption
Class for specifying blob target options when Bucket methods are used.
Bucket.BlobWriteOption
Class for specifying blob write options when Bucket methods are used.
Bucket.BucketSourceOption
Class for specifying bucket source options when Bucket methods are used.
Bucket.Builder
Builder for Bucket.
BucketInfo
Google Storage bucket metadata; See Also: Concepts and Terminology
BucketInfo.AgeDeleteRule (deprecated)
Deprecated. Use a LifecycleRule with a DeleteLifecycleAction and use
LifecycleCondition.Builder.setAge instead.
For example, new DeleteLifecycleAction(1) is equivalent to new
LifecycleRule( LifecycleAction.newDeleteAction(),
LifecycleCondition.newBuilder().setAge(1).build()))
Delete rule class that sets a Time To Live for blobs in the bucket. See Also: Object Lifecycle Management
BucketInfo.Autoclass
BucketInfo.Autoclass.Builder
BucketInfo.Builder
Builder for BucketInfo.
BucketInfo.CreatedBeforeDeleteRule (deprecated)
Deprecated. Use a LifecycleRule with an action DeleteLifecycleAction and a
condition LifecycleCondition.Builder.setCreatedBefore instead.
Delete rule class for blobs in the bucket that have been created before a certain date. See Also: Object Lifecycle Management
BucketInfo.CustomPlacementConfig
The bucket's custom placement configuration for Custom Dual Regions. If using location is
also required.