JavaScript is disabled on your browser.
Skip navigation links

AWS SDK for Java 1.x API Reference - 1.12.795

We announced the upcoming end-of-support for AWS SDK for Java (v1). We recommend that you migrate to AWS SDK for Java v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
com.amazonaws.services.s3.internal

Class ServiceUtils



  • public class ServiceUtils
    extends Object 
    General utility methods used throughout the Amazon Web Services S3 Java client.
    • Constructor Detail

      • ServiceUtils

        public ServiceUtils()
    • Method Detail

      • parseIso8601Date

        public static Date parseIso8601Date(String dateString)
      • formatIso8601Date

        public static String formatIso8601Date(Date date)
      • parseRfc822Date

        public static Date parseRfc822Date(String dateString)
      • formatRfc822Date

        public static String formatRfc822Date(Date date)
      • toByteArray

        public static byte[] toByteArray(String s)
        Safely converts a string to a byte array, first attempting to explicitly use our preferred encoding (UTF-8), and then falling back to the platform's default encoding if for some reason our preferred encoding isn't supported.
        Parameters:
        s - The string to convert to a byte array.
        Returns:
        The byte array contents of the specified string.
      • removeQuotes

        public static String removeQuotes(String s)
        Removes any surrounding quotes from the specified string and returns a new string.
        Parameters:
        s - The string to check for surrounding quotes.
        Returns:
        A new string created from the specified string, minus any surrounding quotes.
      • convertRequestToUrl

        @Deprecated
        public static URL convertRequestToUrl(Request<?> request)
        Deprecated. No longer used. May be removed in a future major version.
        Converts the specified request object into a URL, containing all the specified parameters, the specified request endpoint, etc.
        Parameters:
        request - The request to convert into a URL.
        Returns:
        A new URL representing the specified request.
        Throws:
        SdkClientException - If the request cannot be converted to a well formed URL.
      • convertRequestToUrl

        @Deprecated
        public static URL convertRequestToUrl(Request<?> request,
         boolean removeLeadingSlashInResourcePath)
        Deprecated. No longer used. May be removed in a future major version.
        Converts the specified request object into a URL, containing all the specified parameters, the specified request endpoint, etc.
        Parameters:
        request - The request to convert into a URL.
        removeLeadingSlashInResourcePath - Whether the leading slash in resource-path should be removed before appending to the endpoint.
        Returns:
        A new URL representing the specified request.
        Throws:
        SdkClientException - If the request cannot be converted to a well formed URL.
      • convertRequestToUrl

        public static URL convertRequestToUrl(Request<?> request,
         boolean removeLeadingSlashInResourcePath,
         boolean urlEncode)
        Converts the specified request object into a URL, containing all the specified parameters, the specified request endpoint, etc.
        Parameters:
        request - The request to convert into a URL.
        removeLeadingSlashInResourcePath - Whether the leading slash in resource-path should be removed before appending to the endpoint.
        urlEncode - True if request resource path should be URL encoded
        Returns:
        A new URL representing the specified request.
        Throws:
        SdkClientException - If the request cannot be converted to a well formed URL.
      • join

        public static String join(List<String> strings)
        Returns a new string created by joining each of the strings in the specified list together, with a comma between them.
        Parameters:
        strings - The list of strings to join into a single, comma delimited string list.
        Returns:
        A new string created by joining each of the strings in the specified list together, with a comma between strings.
      • downloadObjectToFile

        public static void downloadObjectToFile(S3Object s3Object,
         File destinationFile,
         boolean performIntegrityCheck,
         boolean appendData)
        Downloads an S3Object, as returned from AmazonS3Client.getObject(com.amazonaws.services.s3.model.GetObjectRequest), to the specified file.
        Parameters:
        s3Object - The S3Object containing a reference to an InputStream containing the object's data.
        destinationFile - The file to store the object's data in.
        performIntegrityCheck - Boolean valuable to indicate whether to perform integrity check
        appendData - appends the data to end of the file.
      • downloadToFile

        public static void downloadToFile(S3Object s3Object,
         File dstfile,
         boolean performIntegrityCheck,
         boolean appendData,
         long expectedFileLength)
        Same as downloadObjectToFile(S3Object, File, boolean, boolean) but has an additional expected file length parameter for integrity checking purposes.
        Parameters:
        expectedFileLength - applicable only when appendData is true; the expected length of the file to append to.
      • createParentDirectoryIfNecessary

        public static void createParentDirectoryIfNecessary(File file)
        Creates the parent directory for a file if it doesn't already exist.
        Parameters:
        file -
        Throws:
        SdkClientException - when creation of parent directory failed.
      • retryableDownloadS3ObjectToFile

        public static S3Object retryableDownloadS3ObjectToFile(File file,
         ServiceUtils.RetryableS3DownloadTask retryableS3DownloadTask,
         boolean appendData)
        Gets an object stored in S3 and downloads it into the specified file. This method includes the one-time retry mechanism after integrity check failure on the downloaded file. It will also return immediately after getting null valued S3Object (when getObject request does not meet the specified constraints).
        Parameters:
        file - The file to store the object's data in.
        retryableS3DownloadTask - The implementation of SafeS3DownloadTask interface which allows user to get access to all the visible variables at the calling site of this method.
      • appendFile

        public static void appendFile(File sourceFile,
         File destinationFile)
        Append the data in sourceFile to destinationFile. Note that the sourceFile is deleted after appending the data.
        Parameters:
        sourceFile - The file that is to be appended.
        destinationFile - The file to append to.
      • isS3USStandardEndpoint

        public static boolean isS3USStandardEndpoint(String endpoint)
      • isS3USEastEndpiont

        public static boolean isS3USEastEndpiont(String endpoint)
        Returns:
        true if the given endpoint is known to be at the region us-east-1. (currently this includes S3 standard, S3 external-1 endpoints).
      • isS3AccelerateEndpoint

        public static boolean isS3AccelerateEndpoint(String endpoint)
      • getPartCount

        public static Integer getPartCount(GetObjectRequest getObjectRequest,
         AmazonS3 s3)
        Returns the part count of the object represented by the getObjectRequest.
        Parameters:
        getObjectRequest - The request to check.
        s3 - The Amazon s3 client.
        Returns:
        The number of parts in the object if it is multipart object, otherwise returns null.
      • getPartSize

        public static long getPartSize(GetObjectRequest getObjectRequest,
         AmazonS3 s3,
         int partNumber)
        Returns the part size of the part
        Parameters:
        getObjectRequest - the request to check
        s3 - the s3 client
        partNumber - the part number
        Returns:
        the part size
      • getLastByteInPart

        public static long getLastByteInPart(AmazonS3 s3,
         GetObjectRequest getObjectRequest,
         Integer partNumber)
        Returns the last byte number in a part of an object.
        Parameters:
        s3 - The Amazon s3 client.
        getObjectRequest - The request to check.
        partNumber - The part in which we need the last byte number.
        Returns:
        The last byte number in the part.
Skip navigation links

AltStyle によって変換されたページ (->オリジナル) /