Class S3RestUtils


  • public final class S3RestUtils
    extends java.lang.Object
    Utilities for handling S3 REST calls.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  S3RestUtils.RestCallable<T>
      An interface representing a callable.
    • Method Detail

      • call

        public static <T> javax.ws.rs.core.Response call​(java.lang.String resource,
                                                         S3RestUtils.RestCallable<T> callable)
        Calls the given S3RestUtils.RestCallable and handles any exceptions thrown.
        Type Parameters:
        T - the return type of the callable
        Parameters:
        resource - the resource (bucket or object) to be operated on
        callable - the callable to call
        Returns:
        the response object
      • getMultipartTemporaryDirForObject

        public static java.lang.String getMultipartTemporaryDirForObject​(java.lang.String bucketPath,
                                                                         java.lang.String objectKey)
        Parameters:
        bucketPath - the bucket path like "/bucket", "/mount/point/bucket"
        objectKey - the object key like "img/2017/9/1/s3.jpg"
        Returns:
        the temporary directory used to hold parts of the object during multipart uploads
      • toS3Date

        public static java.lang.String toS3Date​(long epoch)
        Parameters:
        epoch - the milliseconds from the epoch
        Returns:
        the string representation of the epoch in the S3 date format
      • quoteETag

        public static java.lang.String quoteETag​(java.lang.String etag)
        Parameters:
        etag - the entity tag to be used in the ETag field in the HTTP header
        Returns:
        the etag surrounded by quotes, if etag is already surrounded by quotes, return itself