Package com.totvs.tjf.storage
Interface StorageService
-
public interface StorageService
Implementations of this interface provides supports to a cloud storage service
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
createBucket(String bucketName, Property... properties)
Creates a BucketString
createDeleteSignedUrl(String bucketName, String blobName, String expiresIn, Property... properties)
Creates a delete signed urlString
createDownloadSignedUrl(String bucketName, String blobName, String expiresIn, Property... properties)
Creates a download signed urlString
createUploadSignedUrl(String bucketName, String blobName, String type, String expiresIn, Property... properties)
Creates a upload signed urlvoid
deleteBucket(String bucketName, Property... properties)
Deletes a Bucketvoid
deleteObject(String bucketName, String name, Property... properties)
Deletes an objectboolean
hasBucket(String bucketName, Property... properties)
Checks if the Bucket existsString[]
listObjects(String bucketName, String startsWith, Property... properties)
List object's names based on an optional prefix stringbyte[]
loadObject(String bucketName, String blobname, Property... properties)
Loads the object's contentList<com.google.cloud.storage.Blob>
loadObjectsByIds(String bucketName, List<String> blobIds, Property... properties)
Loads the content of all ids informedList<com.google.cloud.storage.Blob>
loadObjectsByIds(List<com.google.cloud.storage.BlobId> blobIds, Property... properties)
Loads the content of all ids informedvoid
saveObject(String bucketName, String name, String type, byte[] content, Property... properties)
Saves an object
-
-
-
Method Detail
-
createBucket
void createBucket(String bucketName, Property... properties) throws IOException
Creates a Bucket- Parameters:
bucketName
- the bucket's nameproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operation
-
hasBucket
boolean hasBucket(String bucketName, Property... properties) throws IOException
Checks if the Bucket exists- Parameters:
bucketName
- the bucket's nameproperties
- specific connection properties- Returns:
- boolean true if buckets exists or false if not
- Throws:
IOException
- an IO exception of this operation
-
deleteBucket
void deleteBucket(String bucketName, Property... properties) throws IOException, ObjectNotFoundException
Deletes a Bucket- Parameters:
bucketName
- the bucket's nameproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
saveObject
void saveObject(String bucketName, String name, String type, byte[] content, Property... properties) throws IOException, ObjectNotFoundException
Saves an object- Parameters:
bucketName
- the bucket's namename
- the object's nametype
- the object's mime typecontent
- the object's contentproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
loadObject
byte[] loadObject(String bucketName, String blobname, Property... properties) throws IOException, ObjectNotFoundException
Loads the object's content- Parameters:
bucketName
- the bucket's nameblobname
- the object's nameproperties
- specific connection properties- Returns:
- byte[] the object's content
- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
loadObjectsByIds
List<com.google.cloud.storage.Blob> loadObjectsByIds(String bucketName, List<String> blobIds, Property... properties) throws IOException
Loads the content of all ids informed- Parameters:
bucketName
- the bucket's nameblobIds
- list[string] of the object's idsproperties
- specific connection properties- Returns:
- multitype:Blob a list of all the objects content
- Throws:
IOException
- an IO exception of this operation
-
loadObjectsByIds
List<com.google.cloud.storage.Blob> loadObjectsByIds(List<com.google.cloud.storage.BlobId> blobIds, Property... properties) throws IOException
Loads the content of all ids informed- Parameters:
blobIds
- list[BlobId] of the object's idsproperties
- specific connection properties- Returns:
- multitype:Blob a list of all the objects content
- Throws:
IOException
- an IO exception of this operation
-
deleteObject
void deleteObject(String bucketName, String name, Property... properties) throws IOException, ObjectNotFoundException
Deletes an object- Parameters:
bucketName
- the bucket's namename
- the object's nameproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
listObjects
String[] listObjects(String bucketName, String startsWith, Property... properties) throws IOException, ObjectNotFoundException
List object's names based on an optional prefix string- Parameters:
bucketName
- the bucket's namestartsWith
- a prefix stringproperties
- specific connection properties- Returns:
- string[] a list of object's names
- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
createDownloadSignedUrl
String createDownloadSignedUrl(String bucketName, String blobName, String expiresIn, Property... properties) throws IOException, ObjectNotFoundException
Creates a download signed url- Parameters:
bucketName
- the bucket's nameblobName
- the object's nameexpiresIn
- the url expirationproperties
- specific connection properties- Returns:
- the signed url
- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
createDeleteSignedUrl
String createDeleteSignedUrl(String bucketName, String blobName, String expiresIn, Property... properties) throws IOException, ObjectNotFoundException
Creates a delete signed url- Parameters:
bucketName
- the bucket's nameblobName
- the object's nameexpiresIn
- the url expirationproperties
- specific connection properties- Returns:
- string the signed url
- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
createUploadSignedUrl
String createUploadSignedUrl(String bucketName, String blobName, String type, String expiresIn, Property... properties) throws IOException, ObjectNotFoundException
Creates a upload signed url- Parameters:
bucketName
- the bucket's nameblobName
- the object's nametype
- the object's mimetypeproperties
- specific connection propertiesexpiresIn
- the url expiration- Returns:
- string the signed url
- Throws:
IOException
- an IO exception of this operationObjectNotFoundException
- an object not found exception
-
-