Class BlobUtils


  • public class BlobUtils
    extends Object
    Utility functions related to blobs.
    • Field Detail

      • COMPOSE_MAX_BLOBS

        public static final int COMPOSE_MAX_BLOBS
        The maximum number of blobs that can be composed in a single operation.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BlobUtils

        public BlobUtils()
    • Method Detail

      • parseUri

        public static GSBlobIdentifier parseUri​(URI uri)
        Parses a blob id from a Google storage uri, i.e. gs://bucket/foo/bar yields a blob with bucket name "bucket" and object name "foo/bar".
        Parameters:
        uri - The gs uri
        Returns:
        The blob id
      • getTemporaryBucketName

        public static String getTemporaryBucketName​(GSBlobIdentifier finalBlobIdentifier,
                                                    GSFileSystemOptions options)
        Returns the temporary bucket name. If options specifies a temporary bucket name, we use that one; otherwise, we use the bucket name of the final blob.
        Parameters:
        finalBlobIdentifier - The final blob identifier
        options - The file system options
        Returns:
        The temporary bucket name
      • getTemporaryObjectPartialName

        public static String getTemporaryObjectPartialName​(GSBlobIdentifier finalBlobIdentifier)
        Returns a temporary object partial name, i.e. .inprogress/foo/bar/ for the final blob with object name "foo/bar". The included trailing slash is deliberate, so that we can be sure that object names that start with this partial name are, in fact, temporary files associated with the upload of the associated final blob.
        Parameters:
        finalBlobIdentifier - The final blob identifier
        Returns:
        The temporary object partial name
      • getTemporaryObjectName

        public static String getTemporaryObjectName​(GSBlobIdentifier finalBlobIdentifier,
                                                    UUID temporaryObjectId)
        Returns a temporary object name, formed by appending the temporary object id to the temporary object partial name, i.e. .inprogress/foo/bar/abc for the final blob with object name "foo/bar" and temporary object id "abc".
        Parameters:
        finalBlobIdentifier - The final blob identifier
        temporaryObjectId - The temporary object id
        Returns:
        The temporary object name
      • getTemporaryObjectNameWithEntropy

        public static String getTemporaryObjectNameWithEntropy​(GSBlobIdentifier finalBlobIdentifier,
                                                               UUID temporaryObjectId)
        Returns a temporary object name with entropy, formed by adding the temporary object id to the temporary object partial name in both start and end of path, i.e. abc.inprogress/foo/bar/abc for the final blob with object name "foo/bar" and temporary object id "abc".
        Parameters:
        finalBlobIdentifier - The final blob identifier
        temporaryObjectId - The temporary object id
        Returns:
        The temporary object name with entropy
      • getTemporaryBlobIdentifier

        public static GSBlobIdentifier getTemporaryBlobIdentifier​(GSBlobIdentifier finalBlobIdentifier,
                                                                  UUID temporaryObjectId,
                                                                  GSFileSystemOptions options)
        Resolves a temporary blob identifier for a provided temporary object id and the provided options.
        Parameters:
        finalBlobIdentifier - The final blob identifier
        temporaryObjectId - The temporary object id
        options - The file system options
        Returns:
        The blob identifier