The interfaces provided are listed below, along with usage samples.
StorageClient
Service Description: ## API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs.
Resources are named as follows: - Projects are referred to as they are defined by the Resource
Manager API, using strings like projects/123456
or projects/my-string-id
. - Buckets are named
using string names of the form: projects/{project}/buckets/{bucket}
For globally unique
buckets, _
may be substituted for the project. - Objects are uniquely identified by their name
along with the name of the bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest { bucket: 'projects/_/buckets/my-bucket' object: 'my-object' } Note that
object names can contain /
characters, which are treated as any other character (no special
directory semantics).
Sample for StorageClient:
try (StorageClient storageClient = StorageClient.create()) {
StartResumableWriteRequest request =
StartResumableWriteRequest.newBuilder()
.setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setCommonRequestParams(CommonRequestParams.newBuilder().build())
.build();
StartResumableWriteResponse response = storageClient.startResumableWrite(request);
}
Classes
Bucket
A bucket.
Protobuf type google.storage.v2.Bucket
Bucket.Billing
Billing properties of a bucket.
Protobuf type google.storage.v2.Bucket.Billing
Bucket.Billing.Builder
Billing properties of a bucket.
Protobuf type google.storage.v2.Bucket.Billing
Bucket.Builder
A bucket.
Protobuf type google.storage.v2.Bucket
Bucket.Cors
Cross-Origin Response sharing (CORS) properties for a bucket. For more on Cloud Storage and CORS, see https://cloud.google.com/storage/docs/cross-origin. For more on CORS in general, see https://tools.ietf.org/html/rfc6454.
Protobuf type google.storage.v2.Bucket.Cors
Bucket.Cors.Builder
Cross-Origin Response sharing (CORS) properties for a bucket. For more on Cloud Storage and CORS, see https://cloud.google.com/storage/docs/cross-origin. For more on CORS in general, see https://tools.ietf.org/html/rfc6454.
Protobuf type google.storage.v2.Bucket.Cors
Bucket.Encryption
Encryption properties of a bucket.
Protobuf type google.storage.v2.Bucket.Encryption
Bucket.Encryption.Builder
Encryption properties of a bucket.
Protobuf type google.storage.v2.Bucket.Encryption
Bucket.IamConfig
Bucket restriction options.
Protobuf type google.storage.v2.Bucket.IamConfig
Bucket.IamConfig.Builder
Bucket restriction options.
Protobuf type google.storage.v2.Bucket.IamConfig
Bucket.IamConfig.UniformBucketLevelAccess
Settings for Uniform Bucket level access. See https://cloud.google.com/storage/docs/uniform-bucket-level-access.
Protobuf type google.storage.v2.Bucket.IamConfig.UniformBucketLevelAccess
Bucket.IamConfig.UniformBucketLevelAccess.Builder
Settings for Uniform Bucket level access. See https://cloud.google.com/storage/docs/uniform-bucket-level-access.
Protobuf type google.storage.v2.Bucket.IamConfig.UniformBucketLevelAccess
Bucket.Lifecycle
Lifecycle properties of a bucket. For more information, see https://cloud.google.com/storage/docs/lifecycle.
Protobuf type google.storage.v2.Bucket.Lifecycle
Bucket.Lifecycle.Builder
Lifecycle properties of a bucket. For more information, see https://cloud.google.com/storage/docs/lifecycle.
Protobuf type google.storage.v2.Bucket.Lifecycle
Bucket.Lifecycle.Rule
A lifecycle Rule, combining an action to take on an object and a condition which will trigger that action.
Protobuf type google.storage.v2.Bucket.Lifecycle.Rule
Bucket.Lifecycle.Rule.Action
An action to take on an object.
Protobuf type google.storage.v2.Bucket.Lifecycle.Rule.Action
Bucket.Lifecycle.Rule.Action.Builder
An action to take on an object.
Protobuf type google.storage.v2.Bucket.Lifecycle.Rule.Action
Bucket.Lifecycle.Rule.Builder
A lifecycle Rule, combining an action to take on an object and a condition which will trigger that action.
Protobuf type google.storage.v2.Bucket.Lifecycle.Rule
Bucket.Lifecycle.Rule.Condition
A condition of an object which triggers some action.
Protobuf type google.storage.v2.Bucket.Lifecycle.Rule.Condition
Bucket.Lifecycle.Rule.Condition.Builder
A condition of an object which triggers some action.
Protobuf type google.storage.v2.Bucket.Lifecycle.Rule.Condition
Bucket.Logging
Logging-related properties of a bucket.
Protobuf type google.storage.v2.Bucket.Logging
Bucket.Logging.Builder
Logging-related properties of a bucket.
Protobuf type google.storage.v2.Bucket.Logging
Bucket.RetentionPolicy
Retention policy properties of a bucket.
Protobuf type google.storage.v2.Bucket.RetentionPolicy
Bucket.RetentionPolicy.Builder
Retention policy properties of a bucket.
Protobuf type google.storage.v2.Bucket.RetentionPolicy
Bucket.Versioning
Properties of a bucket related to versioning. For more on Cloud Storage versioning, see https://cloud.google.com/storage/docs/object-versioning.
Protobuf type google.storage.v2.Bucket.Versioning
Bucket.Versioning.Builder
Properties of a bucket related to versioning. For more on Cloud Storage versioning, see https://cloud.google.com/storage/docs/object-versioning.
Protobuf type google.storage.v2.Bucket.Versioning
Bucket.Website
Properties of a bucket related to accessing the contents as a static website. For more on hosting a static website via Cloud Storage, see https://cloud.google.com/storage/docs/hosting-static-website.
Protobuf type google.storage.v2.Bucket.Website
Bucket.Website.Builder
Properties of a bucket related to accessing the contents as a static website. For more on hosting a static website via Cloud Storage, see https://cloud.google.com/storage/docs/hosting-static-website.
Protobuf type google.storage.v2.Bucket.Website
BucketAccessControl
An access-control entry.
Protobuf type google.storage.v2.BucketAccessControl
BucketAccessControl.Builder
An access-control entry.
Protobuf type google.storage.v2.BucketAccessControl
ChecksummedData
Message used to convey content being read or written, along with an optional checksum.
Protobuf type google.storage.v2.ChecksummedData
ChecksummedData.Builder
Message used to convey content being read or written, along with an optional checksum.
Protobuf type google.storage.v2.ChecksummedData
CommonObjectRequestParams
Parameters that can be passed to any object request.
Protobuf type google.storage.v2.CommonObjectRequestParams
CommonObjectRequestParams.Builder
Parameters that can be passed to any object request.
Protobuf type google.storage.v2.CommonObjectRequestParams
CommonRequestParams
Parameters that can be passed to any request.
Protobuf type google.storage.v2.CommonRequestParams
CommonRequestParams.Builder
Parameters that can be passed to any request.
Protobuf type google.storage.v2.CommonRequestParams
ContentRange
Specifies a requested range of bytes to download.
Protobuf type google.storage.v2.ContentRange
ContentRange.Builder
Specifies a requested range of bytes to download.
Protobuf type google.storage.v2.ContentRange
Object
An object.
Protobuf type google.storage.v2.Object
Object.Builder
An object.
Protobuf type google.storage.v2.Object
Object.CustomerEncryption
Describes the customer-specified mechanism used to store the data at rest.
Protobuf type google.storage.v2.Object.CustomerEncryption
Object.CustomerEncryption.Builder
Describes the customer-specified mechanism used to store the data at rest.
Protobuf type google.storage.v2.Object.CustomerEncryption
ObjectAccessControl
An access-control entry.
Protobuf type google.storage.v2.ObjectAccessControl
ObjectAccessControl.Builder
An access-control entry.
Protobuf type google.storage.v2.ObjectAccessControl
ObjectChecksums
Message used for storing full (not subrange) object checksums.
Protobuf type google.storage.v2.ObjectChecksums
ObjectChecksums.Builder
Message used for storing full (not subrange) object checksums.
Protobuf type google.storage.v2.ObjectChecksums
Owner
The owner of a specific resource.
Protobuf type google.storage.v2.Owner
Owner.Builder
The owner of a specific resource.
Protobuf type google.storage.v2.Owner
ProjectTeam
Represents the Viewers, Editors, or Owners of a given project.
Protobuf type google.storage.v2.ProjectTeam
ProjectTeam.Builder
Represents the Viewers, Editors, or Owners of a given project.
Protobuf type google.storage.v2.ProjectTeam
QueryWriteStatusRequest
Request object for QueryWriteStatus
.
Protobuf type google.storage.v2.QueryWriteStatusRequest
QueryWriteStatusRequest.Builder
Request object for QueryWriteStatus
.
Protobuf type google.storage.v2.QueryWriteStatusRequest
QueryWriteStatusResponse
Response object for QueryWriteStatus
.
Protobuf type google.storage.v2.QueryWriteStatusResponse
QueryWriteStatusResponse.Builder
Response object for QueryWriteStatus
.
Protobuf type google.storage.v2.QueryWriteStatusResponse
ReadObjectRequest
Request message for ReadObject.
Protobuf type google.storage.v2.ReadObjectRequest
ReadObjectRequest.Builder
Request message for ReadObject.
Protobuf type google.storage.v2.ReadObjectRequest
ReadObjectResponse
Response message for GetObject.
Protobuf type google.storage.v2.ReadObjectResponse
ReadObjectResponse.Builder
Response message for GetObject.
Protobuf type google.storage.v2.ReadObjectResponse
ServiceConstants
Shared constants.
Protobuf type google.storage.v2.ServiceConstants
ServiceConstants.Builder
Shared constants.
Protobuf type google.storage.v2.ServiceConstants
StartResumableWriteRequest
Request message StartResumableWrite.
Protobuf type google.storage.v2.StartResumableWriteRequest
StartResumableWriteRequest.Builder
Request message StartResumableWrite.
Protobuf type google.storage.v2.StartResumableWriteRequest
StartResumableWriteResponse
Response object for StartResumableWrite
.
Protobuf type google.storage.v2.StartResumableWriteResponse
StartResumableWriteResponse.Builder
Response object for StartResumableWrite
.
Protobuf type google.storage.v2.StartResumableWriteResponse
StorageClient
Service Description: ## API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs.
Resources are named as follows: - Projects are referred to as they are defined by the Resource
Manager API, using strings like projects/123456
or projects/my-string-id
. - Buckets are named
using string names of the form: projects/{project}/buckets/{bucket}
For globally unique
buckets, _
may be substituted for the project. - Objects are uniquely identified by their name
along with the name of the bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest { bucket: 'projects/_/buckets/my-bucket' object: 'my-object' } Note that
object names can contain /
characters, which are treated as any other character (no special
directory semantics).
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (StorageClient storageClient = StorageClient.create()) {
StartResumableWriteRequest request =
StartResumableWriteRequest.newBuilder()
.setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setCommonRequestParams(CommonRequestParams.newBuilder().build())
.build();
StartResumableWriteResponse response = storageClient.startResumableWrite(request);
}
Note: close() needs to be called on the StorageClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of StorageSettings to create(). For example:
To customize credentials:
StorageSettings storageSettings =
StorageSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
StorageClient storageClient = StorageClient.create(storageSettings);
To customize the endpoint:
StorageSettings storageSettings = StorageSettings.newBuilder().setEndpoint(myEndpoint).build();
StorageClient storageClient = StorageClient.create(storageSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
StorageGrpc
API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs. Resources are named as follows:
- Projects are referred to as they are defined by the Resource Manager API,
using strings like
projects/123456
orprojects/my-string-id
. - Buckets are named using string names of the form:
projects/{project}/buckets/{bucket}
For globally unique buckets,_
may be substituted for the project. - Objects are uniquely identified by their name along with the name of the
bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest {
bucket: 'projects/_/buckets/my-bucket'
object: 'my-object'
}
Note that object names can contain
/
characters, which are treated as any other character (no special directory semantics).
StorageGrpc.StorageBlockingStub
API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs. Resources are named as follows:
- Projects are referred to as they are defined by the Resource Manager API,
using strings like
projects/123456
orprojects/my-string-id
. - Buckets are named using string names of the form:
projects/{project}/buckets/{bucket}
For globally unique buckets,_
may be substituted for the project. - Objects are uniquely identified by their name along with the name of the
bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest {
bucket: 'projects/_/buckets/my-bucket'
object: 'my-object'
}
Note that object names can contain
/
characters, which are treated as any other character (no special directory semantics).
StorageGrpc.StorageFutureStub
API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs. Resources are named as follows:
- Projects are referred to as they are defined by the Resource Manager API,
using strings like
projects/123456
orprojects/my-string-id
. - Buckets are named using string names of the form:
projects/{project}/buckets/{bucket}
For globally unique buckets,_
may be substituted for the project. - Objects are uniquely identified by their name along with the name of the
bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest {
bucket: 'projects/_/buckets/my-bucket'
object: 'my-object'
}
Note that object names can contain
/
characters, which are treated as any other character (no special directory semantics).
StorageGrpc.StorageImplBase
API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs. Resources are named as follows:
- Projects are referred to as they are defined by the Resource Manager API,
using strings like
projects/123456
orprojects/my-string-id
. - Buckets are named using string names of the form:
projects/{project}/buckets/{bucket}
For globally unique buckets,_
may be substituted for the project. - Objects are uniquely identified by their name along with the name of the
bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest {
bucket: 'projects/_/buckets/my-bucket'
object: 'my-object'
}
Note that object names can contain
/
characters, which are treated as any other character (no special directory semantics).
StorageGrpc.StorageStub
API Overview and Naming Syntax
The GCS gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs. Resources are named as follows:
- Projects are referred to as they are defined by the Resource Manager API,
using strings like
projects/123456
orprojects/my-string-id
. - Buckets are named using string names of the form:
projects/{project}/buckets/{bucket}
For globally unique buckets,_
may be substituted for the project. - Objects are uniquely identified by their name along with the name of the
bucket they belong to, as separate strings in this API. For example:
ReadObjectRequest {
bucket: 'projects/_/buckets/my-bucket'
object: 'my-object'
}
Note that object names can contain
/
characters, which are treated as any other character (no special directory semantics).
StorageProto
StorageSettings
Settings class to configure an instance of StorageClient.
The default instance has everything set to sensible defaults:
- The default service address (storage.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of startResumableWrite to 30 seconds:
StorageSettings.Builder storageSettingsBuilder = StorageSettings.newBuilder();
storageSettingsBuilder
.startResumableWriteSettings()
.setRetrySettings(
storageSettingsBuilder
.startResumableWriteSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
StorageSettings storageSettings = storageSettingsBuilder.build();
StorageSettings.Builder
Builder for StorageSettings.
WriteObjectRequest
Request message for WriteObject.
Protobuf type google.storage.v2.WriteObjectRequest
WriteObjectRequest.Builder
Request message for WriteObject.
Protobuf type google.storage.v2.WriteObjectRequest
WriteObjectResponse
Response message for WriteObject.
Protobuf type google.storage.v2.WriteObjectResponse
WriteObjectResponse.Builder
Response message for WriteObject.
Protobuf type google.storage.v2.WriteObjectResponse
WriteObjectSpec
Describes an attempt to insert an object, possibly over multiple requests.
Protobuf type google.storage.v2.WriteObjectSpec
WriteObjectSpec.Builder
Describes an attempt to insert an object, possibly over multiple requests.
Protobuf type google.storage.v2.WriteObjectSpec
Interfaces
Bucket.BillingOrBuilder
Bucket.CorsOrBuilder
Bucket.EncryptionOrBuilder
Bucket.IamConfig.UniformBucketLevelAccessOrBuilder
Bucket.IamConfigOrBuilder
Bucket.Lifecycle.Rule.ActionOrBuilder
Bucket.Lifecycle.Rule.ConditionOrBuilder
Bucket.Lifecycle.RuleOrBuilder
Bucket.LifecycleOrBuilder
Bucket.LoggingOrBuilder
Bucket.RetentionPolicyOrBuilder
Bucket.VersioningOrBuilder
Bucket.WebsiteOrBuilder
BucketAccessControlOrBuilder
BucketOrBuilder
ChecksummedDataOrBuilder
CommonObjectRequestParamsOrBuilder
CommonRequestParamsOrBuilder
ContentRangeOrBuilder
Object.CustomerEncryptionOrBuilder
ObjectAccessControlOrBuilder
ObjectChecksumsOrBuilder
ObjectOrBuilder
OwnerOrBuilder
ProjectTeamOrBuilder
QueryWriteStatusRequestOrBuilder
QueryWriteStatusResponseOrBuilder
ReadObjectRequestOrBuilder
ReadObjectResponseOrBuilder
ServiceConstantsOrBuilder
StartResumableWriteRequestOrBuilder
StartResumableWriteResponseOrBuilder
WriteObjectRequestOrBuilder
WriteObjectResponseOrBuilder
WriteObjectSpecOrBuilder
Enums
Bucket.IamConfig.PublicAccessPrevention
Public Access Prevention config values.
Protobuf enum google.storage.v2.Bucket.IamConfig.PublicAccessPrevention
PredefinedObjectAcl
Predefined or "canned" aliases for sets of specific object ACL entries.
Protobuf enum google.storage.v2.PredefinedObjectAcl
QueryWriteStatusResponse.WriteStatusCase
ServiceConstants.Values
A collection of constant values meaningful to the Storage API.
Protobuf enum google.storage.v2.ServiceConstants.Values