public interface GoogleCloudStorage
Please read the following document to get familiarity with basic GCS concepts: https://developers.google.com/storage/docs/concepts-techniques
| Modifier and Type | Field and Description |
|---|---|
static String |
PATH_DELIMITER |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases resources used by this instance.
|
void |
copy(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames)
Copies metadata of the given objects.
|
WritableByteChannel |
create(StorageResourceId resourceId)
Creates and opens an object for writing.
|
WritableByteChannel |
create(StorageResourceId resourceId,
CreateObjectOptions options)
Creates and opens an object for writing.
|
void |
create(String bucketName)
Creates a bucket.
|
void |
createEmptyObject(StorageResourceId resourceId)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObject(StorageResourceId resourceId,
CreateObjectOptions options)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObjects(List<StorageResourceId> resourceIds)
Creates a list of empty objects; see
createEmptyObject(StorageResourceId) for
the single-item version of this method. |
void |
createEmptyObjects(List<StorageResourceId> resourceIds,
CreateObjectOptions options)
Creates a list of empty objects; see
createEmptyObject(StorageResourceId) for
the single-item version of this method. |
void |
deleteBuckets(List<String> bucketNames)
Deletes a list of buckets.
|
void |
deleteObjects(List<StorageResourceId> fullObjectNames)
Deletes the given objects.
|
GoogleCloudStorageItemInfo |
getItemInfo(StorageResourceId resourceId)
Gets information about an object or a bucket.
|
List<GoogleCloudStorageItemInfo> |
getItemInfos(List<StorageResourceId> resourceIds)
Gets information about multiple objects and/or buckets.
|
List<GoogleCloudStorageItemInfo> |
listBucketInfo()
Gets a list of GoogleCloudStorageItemInfo for all buckets of this project.
|
List<String> |
listBucketNames()
Gets a list of names of buckets in this project.
|
List<GoogleCloudStorageItemInfo> |
listObjectInfo(String bucketName,
String objectNamePrefix,
String delimiter)
Same name-matching semantics as
listObjectNames except this method retrieves the full
GoogleCloudStorageFileInfo for each item as well; generally the info is already available from
the same "list()" calls, so the only additional cost is dispatching an extra batch request to
retrieve object metadata for all listed *directories*, since these are originally listed as
String prefixes without attached metadata. |
List<String> |
listObjectNames(String bucketName,
String objectNamePrefix,
String delimiter)
Gets names of objects contained in the given bucket and whose names begin with
the given prefix.
|
SeekableReadableByteChannel |
open(StorageResourceId resourceId)
Opens an object for reading.
|
List<GoogleCloudStorageItemInfo> |
updateItems(List<UpdatableItemInfo> itemInfoList)
Attempt to update metadata of the objects referenced within the passed itemInfo objects.
|
void |
waitForBucketEmpty(String bucketName)
Waits for the given bucket to be empty.
|
static final String PATH_DELIMITER
WritableByteChannel create(StorageResourceId resourceId) throws IOException
resourceId - identifies a StorageObjectIOException - on IO errorWritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
resourceId - identifies a StorageObjectoptions - Options to use when creating the objectIOException - on IO errorvoid createEmptyObject(StorageResourceId resourceId) throws IOException
resourceId - identifies a StorageObjectIOException - on IO errorvoid createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
resourceId - identifies a StorageObjectoptions - options to use when creating the objectIOException - on IO errorvoid createEmptyObjects(List<StorageResourceId> resourceIds) throws IOException
createEmptyObject(StorageResourceId) for
the single-item version of this method. Implementations may use different flow than the
single-item version for greater efficiency.IOExceptionvoid createEmptyObjects(List<StorageResourceId> resourceIds, CreateObjectOptions options) throws IOException
createEmptyObject(StorageResourceId) for
the single-item version of this method. Implementations may use different flow than the
single-item version for greater efficiency.IOExceptionSeekableReadableByteChannel open(StorageResourceId resourceId) throws IOException
resourceId - identifies a StorageObjectFileNotFoundException - if the given object does not existIOException - if object exists but cannot be openedvoid create(String bucketName) throws IOException
bucketName - name of the bucket to createIOException - on IO errorvoid deleteBuckets(List<String> bucketNames) throws IOException
bucketNames - name of the buckets to deleteFileNotFoundException - if the given bucket does not existIOException - on IO errorvoid deleteObjects(List<StorageResourceId> fullObjectNames) throws IOException
fullObjectNames - names of objects to delete with their respective bucketNames.FileNotFoundException - if the given object does not existIOException - if object exists but cannot be deletedvoid copy(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames) throws IOException
srcBucketName - 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 casesList<String> listBucketNames() throws IOException
IOExceptionList<GoogleCloudStorageItemInfo> listBucketInfo() throws IOException
IOExceptionList<String> listObjectNames(String bucketName, String objectNamePrefix, String delimiter) throws IOException
bucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullIOException - on IO errorList<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix, String delimiter) throws IOException
listObjectNames except this method retrieves the full
GoogleCloudStorageFileInfo for each item as well; generally the info is already available from
the same "list()" calls, so the only additional cost is dispatching an extra batch request to
retrieve object metadata for all listed *directories*, since these are originally listed as
String prefixes without attached metadata.bucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullIOException - on IO errorGoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException
resourceId - identifies either root, a Bucket, or a StorageObjectIOException - on IO errorList<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds) throws IOException
resourceIds - names of the GCS StorageObjects or Buckets for which to retrieve info.IOException - on IO errorList<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList) throws IOException
IOException - on IO errorvoid close()
void waitForBucketEmpty(String bucketName) throws IOException
IOExceptionCopyright © 2015. All rights reserved.