public class GoogleCloudStorageImpl extends Object implements GoogleCloudStorage
| Modifier and Type | Class and Description |
|---|---|
static interface |
GoogleCloudStorageImpl.BackOffFactory
A factory for producing BackOff objects.
|
GoogleCloudStorage.ListPage<T>MAX_COMPOSE_OBJECTS, MAX_RESULTS_UNLIMITED, PATH_DELIMITER| Constructor and Description |
|---|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.client.auth.oauth2.Credential credential)
Constructs an instance of GoogleCloudStorageImpl.
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.client.auth.oauth2.Credential credential,
Function<List<AccessBoundary>,String> downscopedAccessTokenFn)
Constructs an instance of GoogleCloudStorageImpl.
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) |
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.client.http.HttpRequestInitializer httpRequestInitializer,
Function<List<AccessBoundary>,String> downscopedAccessTokenFn) |
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.services.storage.Storage storage)
Constructs an instance of GoogleCloudStorageImpl.
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.services.storage.Storage storage,
com.google.auth.Credentials credentials)
Constructs an instance of GoogleCloudStorageImpl.
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.services.storage.Storage storage,
com.google.auth.Credentials credentials,
Function<List<AccessBoundary>,String> downscopedAccessTokenFn)
Constructs an instance of GoogleCloudStorageImpl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
See
GoogleCloudStorage.close() for details about expected behavior. |
void |
compose(String bucketName,
List<String> sources,
String destination,
String contentType)
Composes inputs into a single GCS object.
|
GoogleCloudStorageItemInfo |
composeObjects(List<StorageResourceId> sources,
StorageResourceId destination,
CreateObjectOptions options)
Composes inputs into a single GCS object.
|
void |
copy(Map<StorageResourceId,StorageResourceId> sourceToDestinationObjectsMap)
See
GoogleCloudStorage.copy(String, List, String, List) for details about expected
behavior. |
void |
copy(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames)
See
GoogleCloudStorage.copy(String, List, String, List) for details about expected
behavior. |
WritableByteChannel |
create(StorageResourceId resourceId,
CreateObjectOptions options)
Creates and opens an object for writing.
|
void |
createBucket(String bucketName,
CreateBucketOptions options)
See
GoogleCloudStorage.createBucket(String, CreateBucketOptions) for details about
expected behavior. |
void |
createEmptyObject(StorageResourceId resourceId)
See
GoogleCloudStorage.createEmptyObject(StorageResourceId) for details about expected
behavior. |
void |
createEmptyObject(StorageResourceId resourceId,
CreateObjectOptions options)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObjects(List<StorageResourceId> resourceIds)
See
GoogleCloudStorage.createEmptyObjects(List) for details about expected behavior. |
void |
createEmptyObjects(List<StorageResourceId> resourceIds,
CreateObjectOptions options)
Creates a list of empty objects; see
GoogleCloudStorage.createEmptyObject(StorageResourceId) for the
single-item version of this method. |
static GoogleCloudStorageItemInfo |
createItemInfoForBucket(StorageResourceId resourceId,
com.google.api.services.storage.model.Bucket bucket)
Helper for converting a StorageResourceId + Bucket into a GoogleCloudStorageItemInfo.
|
static GoogleCloudStorageItemInfo |
createItemInfoForStorageObject(com.google.api.services.storage.model.StorageObject object) |
static GoogleCloudStorageItemInfo |
createItemInfoForStorageObject(StorageResourceId resourceId,
com.google.api.services.storage.model.StorageObject object)
Helper for converting a StorageResourceId + StorageObject into a GoogleCloudStorageItemInfo.
|
void |
deleteBuckets(List<String> bucketNames)
See
GoogleCloudStorage.deleteBuckets(List) for details about expected behavior. |
void |
deleteObject(StorageResourceId resourceId,
long metaGeneration) |
void |
deleteObjects(List<StorageResourceId> fullObjectNames)
See
GoogleCloudStorage.deleteObjects(List) for details about expected behavior. |
GoogleCloudStorageItemInfo |
getItemInfo(StorageResourceId resourceId)
See
GoogleCloudStorage.getItemInfo(StorageResourceId) for details about expected
behavior. |
List<GoogleCloudStorageItemInfo> |
getItemInfos(List<StorageResourceId> resourceIds)
See
GoogleCloudStorage.getItemInfos(List) for details about expected behavior. |
GoogleCloudStorageOptions |
getOptions()
Retrieve the options that were used to create this GoogleCloudStorage.
|
List<GoogleCloudStorageItemInfo> |
listBucketInfo()
See
GoogleCloudStorage.listBucketInfo() for details about expected behavior. |
List<String> |
listBucketNames()
See
GoogleCloudStorage.listBucketNames() for details about expected behavior. |
List<GoogleCloudStorageItemInfo> |
listObjectInfo(String bucketName,
String objectNamePrefix,
ListObjectOptions listOptions)
Lists
GoogleCloudStorageItemInfo of objects contained in the given bucket and whose
names begin with the given prefix. |
GoogleCloudStorage.ListPage<GoogleCloudStorageItemInfo> |
listObjectInfoPage(String bucketName,
String objectNamePrefix,
ListObjectOptions listOptions,
String pageToken)
The same semantics as
GoogleCloudStorage.listObjectInfo(java.lang.String, java.lang.String), but returns only result of single list request
(1 page). |
SeekableByteChannel |
open(StorageResourceId resourceId,
GoogleCloudStorageReadOptions readOptions)
See
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior. |
List<GoogleCloudStorageItemInfo> |
updateItems(List<UpdatableItemInfo> itemInfoList)
Attempt to update metadata of the objects referenced within the passed itemInfo objects.
|
void |
updateMetadata(GoogleCloudStorageItemInfo itemInfo,
Map<String,byte[]> metadata) |
static void |
validateCopyArguments(Map<StorageResourceId,StorageResourceId> sourceToDestinationObjectsMap,
GoogleCloudStorage gcsImpl)
Validates basic argument constraints like non-null, non-empty Strings, using
Preconditions in addition to checking for src/dst bucket existence and compatibility of bucket
properties such as location and storage-class. |
static void |
validateCopyArguments(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames,
GoogleCloudStorage googleCloudStorage) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, createBucket, listObjectInfo, listObjectInfoPage, openpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.client.auth.oauth2.Credential credential) throws IOException
options - options to customize behaviorcredential - OAuth2 credential that allows access to GCSIOException - on IO errorpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.client.auth.oauth2.Credential credential, Function<List<AccessBoundary>,String> downscopedAccessTokenFn) throws IOException
options - options to customize behaviorcredential - OAuth2 credential that allows access to GCSdownscopedAccessTokenFn - Function that generates downscoped access token.IOException - on IO errorpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) throws IOException
IOExceptionpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.client.http.HttpRequestInitializer httpRequestInitializer, Function<List<AccessBoundary>,String> downscopedAccessTokenFn) throws IOException
IOExceptionpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.services.storage.Storage storage)
storage - Storage to use for I/O.public GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.services.storage.Storage storage, com.google.auth.Credentials credentials)
options - GoogleCloudStorageOptions to use to initialize the object.storage - Storage to use for I/O.credentials - OAuth2 credentials that allows access to GCSpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.services.storage.Storage storage, com.google.auth.Credentials credentials, Function<List<AccessBoundary>,String> downscopedAccessTokenFn)
options - GoogleCloudStorageOptions to use to initialize the object.storage - Storage to use for I/O.credentials - OAuth2 credentials that allows access to GCSdownscopedAccessTokenFn - Function that generates downscoped access token.public static void validateCopyArguments(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames, GoogleCloudStorage googleCloudStorage) throws IOException
IOExceptionpublic GoogleCloudStorageOptions getOptions()
GoogleCloudStoragegetOptions in interface GoogleCloudStoragepublic WritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStorageresourceId
contains a known generationId or a generationId of 0, it is used instead of any "overwrite"
settings in the provided CreateObjectOptions (overwrite will only succeed if the
provided generationId matches the existing object, where a generationId of 0 indicates no
existing object expected).create in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - Options to use when creating the objectIOException - on IO errorpublic void createBucket(String bucketName, CreateBucketOptions options) throws IOException
GoogleCloudStorage.createBucket(String, CreateBucketOptions) for details about
expected behavior.createBucket in interface GoogleCloudStoragebucketName - name of the bucket to createoptions - options to use when creating bucketIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStorageGoogleCloudStorage.create(StorageResourceId) for the behavior if StorageResourceId.getGenerationId() is
explicitly set.createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - options to use when creating the objectIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId) throws IOException
GoogleCloudStorage.createEmptyObject(StorageResourceId) for details about expected
behavior.createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - on IO errorpublic void updateMetadata(GoogleCloudStorageItemInfo itemInfo, Map<String,byte[]> metadata) throws IOException
IOExceptionpublic void createEmptyObjects(List<StorageResourceId> resourceIds, CreateObjectOptions options) throws IOException
GoogleCloudStorageGoogleCloudStorage.createEmptyObject(StorageResourceId) for the
single-item version of this method. Implementations may use different flow than the single-item
version for greater efficiency. See GoogleCloudStorage.create(StorageResourceId) for the behavior if
StorageResourceId.getGenerationId() is explicitly set.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic void createEmptyObjects(List<StorageResourceId> resourceIds) throws IOException
GoogleCloudStorage.createEmptyObjects(List) for details about expected behavior.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic SeekableByteChannel open(StorageResourceId resourceId, GoogleCloudStorageReadOptions readOptions) throws IOException
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior.open in interface GoogleCloudStorageresourceId - identifies a StorageObjectreadOptions - Fine-grained options for behaviors of retries, buffering, etc.FileNotFoundException - if the given object does not existIOException - if object exists but cannot be openedpublic void deleteBuckets(List<String> bucketNames) throws IOException
GoogleCloudStorage.deleteBuckets(List) for details about expected behavior.deleteBuckets in interface GoogleCloudStoragebucketNames - name of the buckets to deleteFileNotFoundException - if the given bucket does not existIOException - on IO errorpublic void deleteObject(StorageResourceId resourceId, long metaGeneration) throws IOException
IOExceptionpublic void deleteObjects(List<StorageResourceId> fullObjectNames) throws IOException
GoogleCloudStorage.deleteObjects(List) for details about expected behavior.deleteObjects in interface GoogleCloudStoragefullObjectNames - names of objects to delete with their respective bucketNames.FileNotFoundException - if the given object does not existIOException - if object exists but cannot be deletedpublic static void validateCopyArguments(Map<StorageResourceId,StorageResourceId> sourceToDestinationObjectsMap, GoogleCloudStorage gcsImpl) throws IOException
Preconditions in addition to checking for src/dst bucket existence and compatibility of bucket
properties such as location and storage-class.gcsImpl - A GoogleCloudStorage for retrieving bucket info via getItemInfo, but only if
srcBucketName != dstBucketName; passed as a parameter so that this static method can be
used by other implementations of GoogleCloudStorage that want to preserve the validation
behavior of GoogleCloudStorageImpl, including disallowing cross-location copies.IOExceptionpublic void copy(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames) throws IOException
GoogleCloudStorage.copy(String, List, String, List) for details about expected
behavior.copy in interface GoogleCloudStoragesrcBucketName - name of the bucket containing the objects to copysrcObjectNames - names of the objects to copydstBucketName - name of the bucket to copy todstObjectNames - names of the objects after copyFileNotFoundException - if the source object or the destination bucket does not
existIOException - in all other error casespublic void copy(Map<StorageResourceId,StorageResourceId> sourceToDestinationObjectsMap) throws IOException
GoogleCloudStorage.copy(String, List, String, List) for details about expected
behavior.copy in interface GoogleCloudStoragesourceToDestinationObjectsMap - map of destination objects to be copied, keyed by sourceFileNotFoundException - if the source object or the destination bucket does not
existIOException - in all other error casespublic List<String> listBucketNames() throws IOException
GoogleCloudStorage.listBucketNames() for details about expected behavior.listBucketNames in interface GoogleCloudStorageIOExceptionpublic List<GoogleCloudStorageItemInfo> listBucketInfo() throws IOException
GoogleCloudStorage.listBucketInfo() for details about expected behavior.listBucketInfo in interface GoogleCloudStorageIOExceptionpublic List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix, ListObjectOptions listOptions) throws IOException
GoogleCloudStorageGoogleCloudStorageItemInfo of objects contained in the given bucket and whose
names begin with the given prefix.
Note: Although GCS does not implement a file system, it treats objects that contain a
delimiter (ListObjectOptions.getDelimiter()) as different from other objects when
listing objects. This will be clearer with an example.
Consider a bucket with objects: o1, d1/, d1/o1, d1/o2
prefix == null and delimiter == /, we get: d1/, o1
With prefix == null and delimiter == null, we get: o1, d1/, d1/o1, d1/o2
Thus when delimiter is null, the entire key name is considered an opaque string,
otherwise only the part up to the first delimiter is considered.
listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desiredlistOptions - options to use when listing objectsIOException - on IO errorGoogleCloudStorage.listObjectInfo(String, String, ListObjectOptions)public GoogleCloudStorage.ListPage<GoogleCloudStorageItemInfo> listObjectInfoPage(String bucketName, String objectNamePrefix, ListObjectOptions listOptions, String pageToken) throws IOException
GoogleCloudStorageGoogleCloudStorage.listObjectInfo(java.lang.String, java.lang.String), but returns only result of single list request
(1 page).listObjectInfoPage in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desiredlistOptions - options to use when listing objectspageToken - the page tokenGoogleCloudStorage.ListPage object with listed GoogleCloudStorageItemInfos and next page
token if anyIOException - on IO errorGoogleCloudStorage.listObjectInfoPage(String, String, ListObjectOptions, String)public static GoogleCloudStorageItemInfo createItemInfoForBucket(StorageResourceId resourceId, com.google.api.services.storage.model.Bucket bucket)
public static GoogleCloudStorageItemInfo createItemInfoForStorageObject(com.google.api.services.storage.model.StorageObject object)
public static GoogleCloudStorageItemInfo createItemInfoForStorageObject(StorageResourceId resourceId, com.google.api.services.storage.model.StorageObject object)
public List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds) throws IOException
GoogleCloudStorage.getItemInfos(List) for details about expected behavior.getItemInfos in interface GoogleCloudStorageresourceIds - names of the GCS StorageObjects or Buckets for which to retrieve info.IOException - on IO errorpublic List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList) throws IOException
GoogleCloudStorageupdateItems in interface GoogleCloudStorageIOException - on IO errorpublic GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException
GoogleCloudStorage.getItemInfo(StorageResourceId) for details about expected
behavior.getItemInfo in interface GoogleCloudStorageresourceId - identifies either root, a Bucket, or a StorageObjectIOException - on IO errorpublic void close()
GoogleCloudStorage.close() for details about expected behavior.close in interface GoogleCloudStoragepublic void compose(String bucketName, List<String> sources, String destination, String contentType) throws IOException
GoogleCloudStoragecompose in interface GoogleCloudStoragebucketName - name of the bucket containing the sources and the destinationsources - names of the objects to be composeddestination - name of the resulting objectcontentType - content-type of composed objectIOException - if the Compose operation was unsuccessfulpublic GoogleCloudStorageItemInfo composeObjects(List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options) throws IOException
GoogleCloudStorageoptions. Overwrite semantics for the destination object will follow the
same semantics as GoogleCloudStorage.create(StorageResourceId, CreateObjectOptions). See GoogleCloudStorage.create(StorageResourceId) for the behavior if StorageResourceId.getGenerationId() is
explicitly set. The bucket must be the same for all sources and the destination.composeObjects in interface GoogleCloudStorageIOExceptionCopyright © 2022. All rights reserved.