public class Bucket extends BucketInfo
Objects of this class are immutable. Operations that modify the bucket like update(com.google.cloud.storage.Storage.BucketTargetOption...)
return a new object. To get a Bucket object with the most recent information use
reload(com.google.cloud.storage.Bucket.BucketSourceOption...). Bucket adds a layer of service-related functionality over
BucketInfo.
| Modifier and Type | Class and Description |
|---|---|
static class |
Bucket.BlobTargetOption
Class for specifying blob target options when
Bucket methods are used. |
static class |
Bucket.BlobWriteOption
Class for specifying blob write options when
Bucket methods are used. |
static class |
Bucket.BucketSourceOption
Class for specifying bucket source options when
Bucket methods are used. |
static class |
Bucket.Builder
Builder for
Bucket. |
BucketInfo.AgeDeleteRule, BucketInfo.CreatedBeforeDeleteRule, BucketInfo.DeleteRule, BucketInfo.IsLiveDeleteRule, BucketInfo.NumNewerVersionsDeleteRule| Modifier and Type | Method and Description |
|---|---|
Blob |
create(String blob,
byte[] content,
Bucket.BlobTargetOption... options)
Creates a new blob in this bucket.
|
Blob |
create(String blob,
byte[] content,
String contentType,
Bucket.BlobTargetOption... options)
Creates a new blob in this bucket.
|
Blob |
create(String blob,
InputStream content,
Bucket.BlobWriteOption... options)
Creates a new blob in this bucket.
|
Blob |
create(String blob,
InputStream content,
String contentType,
Bucket.BlobWriteOption... options)
Creates a new blob in this bucket.
|
boolean |
delete(Bucket.BucketSourceOption... options)
Deletes this bucket.
|
boolean |
equals(Object obj) |
boolean |
exists(Bucket.BucketSourceOption... options)
Checks if this bucket exists.
|
List<Blob> |
get(Iterable<String> blobNames)
Returns a list of requested blobs in this bucket.
|
Blob |
get(String blob,
Storage.BlobGetOption... options)
Returns the requested blob in this bucket or
null if not found. |
List<Blob> |
get(String blobName1,
String blobName2,
String... blobNames)
Returns a list of requested blobs in this bucket.
|
int |
hashCode() |
Page<Blob> |
list(Storage.BlobListOption... options)
Returns the paginated list of
Blob in this bucket. |
Bucket |
reload(Bucket.BucketSourceOption... options)
Fetches current bucket's latest information.
|
Storage |
storage()
Returns the bucket's
Storage object used to issue requests. |
Bucket.Builder |
toBuilder()
Returns a builder for the current bucket.
|
Bucket |
update(Storage.BucketTargetOption... options)
Updates the bucket's information.
|
acl, builder, cors, createTime, defaultAcl, deleteRules, etag, generatedId, indexPage, location, metageneration, name, notFoundPage, of, owner, selfLink, storageClass, toString, versioningEnabledpublic boolean exists(Bucket.BucketSourceOption... options)
StorageException - upon failurepublic Bucket reload(Bucket.BucketSourceOption... options)
null if the bucket does not exist.options - bucket read optionsBucket object with latest information or null if not foundStorageException - upon failurepublic Bucket update(Storage.BucketTargetOption... options)
Bucket object
is returned. By default no checks are made on the metadata generation of the current bucket.
If you want to update the information only if the current bucket metadata are at their latest
version use the metagenerationMatch option:
bucket.update(BucketTargetOption.metagenerationMatch())options - update optionsBucket object with updated informationStorageException - upon failurepublic boolean delete(Bucket.BucketSourceOption... options)
options - bucket delete optionstrue if bucket was deleted, false if it was not foundStorageException - upon failurepublic Page<Blob> list(Storage.BlobListOption... options)
Blob in this bucket.options - options for listing blobsStorageException - upon failurepublic Blob get(String blob, Storage.BlobGetOption... options)
null if not found.blob - name of the requested bloboptions - blob search optionsStorageException - upon failurepublic List<Blob> get(String blobName1, String blobName2, String... blobNames)
blobName1 - first blob to getblobName2 - second blob to getblobNames - other blobs to getBlob objectsStorageException - upon failurepublic List<Blob> get(Iterable<String> blobNames)
blobNames - blobs to getBlob objectsStorageException - upon failurepublic Blob create(String blob, byte[] content, String contentType, Bucket.BlobTargetOption... options)
content.
For large content, Blob.writer(com.google.cloud.storage.Storage.BlobWriteOption...)
is recommended as it uses resumable upload. MD5 and CRC32C hashes of content are
computed and used for validating transferred data.blob - a blob namecontent - the blob contentcontentType - the blob content typeoptions - options for blob creationStorageException - upon failurepublic Blob create(String blob, InputStream content, String contentType, Bucket.BlobWriteOption... options)
content.
For large content, Blob.writer(com.google.cloud.storage.Storage.BlobWriteOption...)
is recommended as it uses resumable upload.blob - a blob namecontent - the blob content as a streamcontentType - the blob content typeoptions - options for blob creationStorageException - upon failurepublic Blob create(String blob, byte[] content, Bucket.BlobTargetOption... options)
content.
For large content, Blob.writer(com.google.cloud.storage.Storage.BlobWriteOption...)
is recommended as it uses resumable upload. MD5 and CRC32C hashes of content are
computed and used for validating transferred data.blob - a blob namecontent - the blob contentoptions - options for blob creationStorageException - upon failurepublic Blob create(String blob, InputStream content, Bucket.BlobWriteOption... options)
content.
For large content, Blob.writer(com.google.cloud.storage.Storage.BlobWriteOption...)
is recommended as it uses resumable upload.blob - a blob namecontent - the blob content as a streamoptions - options for blob creationStorageException - upon failurepublic Storage storage()
Storage object used to issue requests.public Bucket.Builder toBuilder()
BucketInfotoBuilder in class BucketInfopublic final boolean equals(Object obj)
equals in class BucketInfopublic final int hashCode()
hashCode in class BucketInfoCopyright © 2016 Google. All rights reserved.