public class GoogleCloudStorageImpl extends java.lang.Object implements GoogleCloudStorage
| Modifier and Type | Class and Description |
|---|---|
static interface |
GoogleCloudStorageImpl.BackOffFactory
A factory for producing BackOff objects.
|
GoogleCloudStorage.ListPage<T>| Modifier and Type | Field and Description |
|---|---|
static int |
BUCKET_EMPTY_MAX_RETRIES |
static int |
BUCKET_EMPTY_WAIT_TIME_MS |
MAX_COMPOSE_OBJECTS, MAX_RESULTS_UNLIMITED, PATH_DELIMITER| Modifier | Constructor and Description |
|---|---|
protected |
GoogleCloudStorageImpl() |
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.client.auth.oauth2.Credential credential)
Constructs an instance of GoogleCloudStorageImpl.
|
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.services.storage.Storage gcs)
Constructs an instance of GoogleCloudStorageImpl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
See
GoogleCloudStorage.close() for details about expected behavior. |
void |
compose(java.lang.String bucketName,
java.util.List<java.lang.String> sources,
java.lang.String destination,
java.lang.String contentType)
Composes inputs into a single GCS object.
|
GoogleCloudStorageItemInfo |
composeObjects(java.util.List<StorageResourceId> sources,
StorageResourceId destination,
CreateObjectOptions options)
Composes inputs into a single GCS object.
|
void |
copy(java.lang.String srcBucketName,
java.util.List<java.lang.String> srcObjectNames,
java.lang.String dstBucketName,
java.util.List<java.lang.String> dstObjectNames)
See
GoogleCloudStorage.copy(String, List, String, List) for details about expected
behavior. |
java.nio.channels.WritableByteChannel |
create(StorageResourceId resourceId)
See
GoogleCloudStorage.create(StorageResourceId) for details about expected behavior. |
java.nio.channels.WritableByteChannel |
create(StorageResourceId resourceId,
CreateObjectOptions options)
Creates and opens an object for writing.
|
void |
create(java.lang.String bucketName)
See
GoogleCloudStorage.create(String) for details about expected behavior. |
void |
create(java.lang.String bucketName,
CreateBucketOptions options)
See
GoogleCloudStorage.create(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(java.util.List<StorageResourceId> resourceIds)
See
GoogleCloudStorage.createEmptyObjects(List) for details about
expected behavior. |
void |
createEmptyObjects(java.util.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(StorageResourceId resourceId,
com.google.api.services.storage.model.StorageObject object)
Helper for converting a StorageResourceId + StorageObject into a GoogleCloudStorageItemInfo.
|
void |
deleteBuckets(java.util.List<java.lang.String> bucketNames)
See
GoogleCloudStorage.deleteBuckets(List) for details about expected behavior. |
void |
deleteObjects(java.util.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. |
java.util.List<GoogleCloudStorageItemInfo> |
getItemInfos(java.util.List<StorageResourceId> resourceIds)
See
GoogleCloudStorage.getItemInfos(List) for details about expected behavior. |
GoogleCloudStorageOptions |
getOptions()
Retrieve the options that were used to create this GoogleCloudStorage.
|
java.util.List<GoogleCloudStorageItemInfo> |
listBucketInfo()
See
GoogleCloudStorage.listBucketInfo() for details about expected behavior. |
java.util.List<java.lang.String> |
listBucketNames()
See
GoogleCloudStorage.listBucketNames() for details about expected behavior. |
java.util.List<GoogleCloudStorageItemInfo> |
listObjectInfo(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter)
See
GoogleCloudStorage.listObjectInfo(String, String, String) for details about
expected behavior. |
java.util.List<GoogleCloudStorageItemInfo> |
listObjectInfo(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter,
long maxResults)
See
GoogleCloudStorage.listObjectInfo(String, String, String, long) for details about
expected behavior. |
GoogleCloudStorage.ListPage<GoogleCloudStorageItemInfo> |
listObjectInfoPage(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter,
java.lang.String pageToken)
The same semantics as
GoogleCloudStorage.listObjectInfo(java.lang.String, java.lang.String, java.lang.String), but returns only result of single list request
(1 page). |
java.util.List<java.lang.String> |
listObjectNames(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter)
See
GoogleCloudStorage.listObjectNames(String, String, String)
for details about expected behavior. |
java.util.List<java.lang.String> |
listObjectNames(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter,
long maxResults)
See
GoogleCloudStorage.listObjectNames(String, String, String, long) for details about
expected behavior. |
java.nio.channels.SeekableByteChannel |
open(StorageResourceId resourceId)
See
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior. |
java.nio.channels.SeekableByteChannel |
open(StorageResourceId resourceId,
GoogleCloudStorageReadOptions readOptions)
See
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior. |
java.util.List<GoogleCloudStorageItemInfo> |
updateItems(java.util.List<UpdatableItemInfo> itemInfoList)
Attempt to update metadata of the objects referenced within the passed itemInfo objects.
|
static void |
validateCopyArguments(java.lang.String srcBucketName,
java.util.List<java.lang.String> srcObjectNames,
java.lang.String dstBucketName,
java.util.List<java.lang.String> dstObjectNames,
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. |
void |
waitForBucketEmpty(java.lang.String bucketName)
See
GoogleCloudStorage.waitForBucketEmpty(String) for details about expected behavior. |
public static final int BUCKET_EMPTY_MAX_RETRIES
public static final int BUCKET_EMPTY_WAIT_TIME_MS
public GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.client.auth.oauth2.Credential credential) throws java.io.IOException
credential - OAuth2 credential that allows access to GCSjava.io.IOException - on IO errorpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.services.storage.Storage gcs)
gcs - Preconstructed Storage to use for I/O.protected GoogleCloudStorageImpl()
public GoogleCloudStorageOptions getOptions()
GoogleCloudStoragegetOptions in interface GoogleCloudStoragepublic java.nio.channels.WritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws java.io.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 objectjava.io.IOException - on IO errorpublic java.nio.channels.WritableByteChannel create(StorageResourceId resourceId) throws java.io.IOException
GoogleCloudStorage.create(StorageResourceId) for details about expected behavior.create in interface GoogleCloudStorageresourceId - identifies a StorageObjectjava.io.IOException - on IO errorpublic void create(java.lang.String bucketName)
throws java.io.IOException
GoogleCloudStorage.create(String) for details about expected behavior.create in interface GoogleCloudStoragebucketName - name of the bucket to createjava.io.IOException - on IO errorpublic void create(java.lang.String bucketName,
CreateBucketOptions options)
throws java.io.IOException
GoogleCloudStorage.create(String, CreateBucketOptions) for details about expected
behavior.create in interface GoogleCloudStoragebucketName - name of the bucket to createoptions - options to use when creating bucketjava.io.IOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws java.io.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 objectjava.io.IOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId) throws java.io.IOException
GoogleCloudStorage.createEmptyObject(StorageResourceId) for details about
expected behavior.createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectjava.io.IOException - on IO errorpublic void createEmptyObjects(java.util.List<StorageResourceId> resourceIds, CreateObjectOptions options) throws java.io.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 GoogleCloudStoragejava.io.IOExceptionpublic void createEmptyObjects(java.util.List<StorageResourceId> resourceIds) throws java.io.IOException
GoogleCloudStorage.createEmptyObjects(List) for details about
expected behavior.createEmptyObjects in interface GoogleCloudStoragejava.io.IOExceptionpublic java.nio.channels.SeekableByteChannel open(StorageResourceId resourceId) throws java.io.IOException
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior.open in interface GoogleCloudStorageresourceId - identifies a StorageObjectjava.io.FileNotFoundException - if the given object does not existjava.io.IOException - if object exists but cannot be openedpublic java.nio.channels.SeekableByteChannel open(StorageResourceId resourceId, GoogleCloudStorageReadOptions readOptions) throws java.io.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.java.io.FileNotFoundException - if the given object does not existjava.io.IOException - if object exists but cannot be openedpublic void deleteBuckets(java.util.List<java.lang.String> bucketNames)
throws java.io.IOException
GoogleCloudStorage.deleteBuckets(List) for details about expected behavior.deleteBuckets in interface GoogleCloudStoragebucketNames - name of the buckets to deletejava.io.FileNotFoundException - if the given bucket does not existjava.io.IOException - on IO errorpublic void deleteObjects(java.util.List<StorageResourceId> fullObjectNames) throws java.io.IOException
GoogleCloudStorage.deleteObjects(List) for details about expected behavior.deleteObjects in interface GoogleCloudStoragefullObjectNames - names of objects to delete with their respective bucketNames.java.io.FileNotFoundException - if the given object does not existjava.io.IOException - if object exists but cannot be deletedpublic static void validateCopyArguments(java.lang.String srcBucketName,
java.util.List<java.lang.String> srcObjectNames,
java.lang.String dstBucketName,
java.util.List<java.lang.String> dstObjectNames,
GoogleCloudStorage gcsImpl)
throws java.io.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.java.io.IOExceptionpublic void copy(java.lang.String srcBucketName,
java.util.List<java.lang.String> srcObjectNames,
java.lang.String dstBucketName,
java.util.List<java.lang.String> dstObjectNames)
throws java.io.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 copyjava.io.FileNotFoundException - if the source object or the destination bucket does not
existjava.io.IOException - in all other error casespublic java.util.List<java.lang.String> listBucketNames()
throws java.io.IOException
GoogleCloudStorage.listBucketNames() for details about expected behavior.listBucketNames in interface GoogleCloudStoragejava.io.IOExceptionpublic java.util.List<GoogleCloudStorageItemInfo> listBucketInfo() throws java.io.IOException
GoogleCloudStorage.listBucketInfo() for details about expected behavior.listBucketInfo in interface GoogleCloudStoragejava.io.IOExceptionpublic java.util.List<java.lang.String> listObjectNames(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter)
throws java.io.IOException
GoogleCloudStorage.listObjectNames(String, String, String)
for details about expected behavior.listObjectNames in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nulljava.io.IOException - on IO errorpublic java.util.List<java.lang.String> listObjectNames(java.lang.String bucketName,
java.lang.String objectNamePrefix,
java.lang.String delimiter,
long maxResults)
throws java.io.IOException
GoogleCloudStorage.listObjectNames(String, String, String, long) for details about
expected behavior.listObjectNames in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullmaxResults - maximum number of results to return,
unlimited if negative or zerojava.io.IOException - on IO errorpublic java.util.List<GoogleCloudStorageItemInfo> listObjectInfo(java.lang.String bucketName, java.lang.String objectNamePrefix, java.lang.String delimiter) throws java.io.IOException
GoogleCloudStorage.listObjectInfo(String, String, String) for details about
expected behavior.listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nulljava.io.IOException - on IO errorpublic java.util.List<GoogleCloudStorageItemInfo> listObjectInfo(java.lang.String bucketName, java.lang.String objectNamePrefix, java.lang.String delimiter, long maxResults) throws java.io.IOException
GoogleCloudStorage.listObjectInfo(String, String, String, long) for details about
expected behavior.listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullmaxResults - maximum number of results to return, unlimited if negative or zerojava.io.IOException - on IO errorpublic GoogleCloudStorage.ListPage<GoogleCloudStorageItemInfo> listObjectInfoPage(java.lang.String bucketName, java.lang.String objectNamePrefix, java.lang.String delimiter, java.lang.String pageToken) throws java.io.IOException
GoogleCloudStorageGoogleCloudStorage.listObjectInfo(java.lang.String, 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 desireddelimiter - delimiter to use (typically "/"), otherwise nullpageToken - the page tokenGoogleCloudStorage.ListPage object with listed GoogleCloudStorageItemInfos and next page
token if anyjava.io.IOException - on IO errorpublic static GoogleCloudStorageItemInfo createItemInfoForBucket(StorageResourceId resourceId, com.google.api.services.storage.model.Bucket bucket)
public static GoogleCloudStorageItemInfo createItemInfoForStorageObject(StorageResourceId resourceId, com.google.api.services.storage.model.StorageObject object)
public java.util.List<GoogleCloudStorageItemInfo> getItemInfos(java.util.List<StorageResourceId> resourceIds) throws java.io.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.java.io.IOException - on IO errorpublic java.util.List<GoogleCloudStorageItemInfo> updateItems(java.util.List<UpdatableItemInfo> itemInfoList) throws java.io.IOException
GoogleCloudStorageupdateItems in interface GoogleCloudStoragejava.io.IOException - on IO errorpublic GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws java.io.IOException
GoogleCloudStorage.getItemInfo(StorageResourceId) for details about expected
behavior.getItemInfo in interface GoogleCloudStorageresourceId - identifies either root, a Bucket, or a StorageObjectjava.io.IOException - on IO errorpublic void close()
GoogleCloudStorage.close() for details about expected behavior.close in interface GoogleCloudStoragepublic void waitForBucketEmpty(java.lang.String bucketName)
throws java.io.IOException
GoogleCloudStorage.waitForBucketEmpty(String) for details about expected behavior.waitForBucketEmpty in interface GoogleCloudStoragejava.io.IOExceptionpublic void compose(java.lang.String bucketName,
java.util.List<java.lang.String> sources,
java.lang.String destination,
java.lang.String contentType)
throws java.io.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 objectjava.io.IOException - if the Compose operation was unsuccessfulpublic GoogleCloudStorageItemInfo composeObjects(java.util.List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options) throws java.io.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 GoogleCloudStoragejava.io.IOExceptionCopyright © 2019. All rights reserved.