public class ServiceUtils extends Object
限定符和类型 | 类和说明 |
---|---|
static interface |
ServiceUtils.RetryableS3DownloadTask
Interface for the task of downloading object from S3 to a specific file,
enabling one-time retry mechanism after integrity check failure
on the downloaded file.
|
构造器和说明 |
---|
ServiceUtils() |
限定符和类型 | 方法和说明 |
---|---|
static URL |
convertRequestToUrl(Request<?> request)
Converts the specified request object into a URL, containing all the
specified parameters, the specified request endpoint, etc.
|
static URL |
convertRequestToUrl(Request<?> request,
boolean removeLeadingSlashInResourcePath)
Converts the specified request object into a URL, containing all the
specified parameters, the specified request endpoint, etc.
|
static void |
downloadObjectToFile(S3Object s3Object,
File destinationFile,
boolean performIntegrityCheck)
Downloads an S3Object, as returned from
SCSClient#getObject(com.amazonaws.services.s3.model.GetObjectRequest) ,
to the specified file. |
static String |
formatIso8601Date(Date date) |
static String |
formatRfc822Date(Date date) |
static boolean |
isMultipartUploadETag(String eTag)
Returns true if the specified ETag was from a multipart upload.
|
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.
|
static Date |
parseIso8601Date(String dateString) |
static Date |
parseRfc822Date(String dateString) |
static String |
removeQuotes(String s)
Removes any surrounding quotes from the specified string and returns a
new string.
|
static S3Object |
retryableDownloadS3ObjectToFile(File file,
ServiceUtils.RetryableS3DownloadTask retryableS3DownloadTask)
Gets an object stored in S3 and downloads it into the specified file.
|
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.
|
protected static final DateUtils dateUtils
public static Date parseIso8601Date(String dateString) throws ParseException
ParseException
public static Date parseRfc822Date(String dateString) throws ParseException
ParseException
public static boolean isMultipartUploadETag(String eTag)
eTag
- The ETag to test.public static byte[] toByteArray(String s)
s
- The string to convert to a byte array.public static String removeQuotes(String s)
s
- The string to check for surrounding quotes.public static URL convertRequestToUrl(Request<?> request)
request
- The request to convert into a URL.AmazonClientException
- If the request cannot be converted to a well formed URL.public static URL convertRequestToUrl(Request<?> request, boolean removeLeadingSlashInResourcePath)
request
- The request to convert into a URL.removeLeadingSlashInResourcePath
- Whether the leading slash in resource-path should be removed
before appending to the endpoint.AmazonClientException
- If the request cannot be converted to a well formed URL.public static String join(List<String> strings)
strings
- The list of strings to join into a single, comma delimited
string list.public static void downloadObjectToFile(S3Object s3Object, File destinationFile, boolean performIntegrityCheck)
SCSClient#getObject(com.amazonaws.services.s3.model.GetObjectRequest)
,
to the specified file.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 do the integrity check or notpublic static S3Object retryableDownloadS3ObjectToFile(File file, ServiceUtils.RetryableS3DownloadTask retryableS3DownloadTask)
file
- The file to store the object's data in.safeS3DownloadTask
- The implementation of SafeS3DownloadTask interface which allows user to
get access to all the visible variables at the calling site of this method.Copyright © 2016. All rights reserved.