com.netease.cloud.services.nos.internal
public class ServiceUtils extends Object
Constructor and Description |
---|
ServiceUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
computeMD5Hash(byte[] data)
Computes the MD5 hash of the given data and returns it as a hex string.
|
static byte[] |
computeMD5Hash(InputStream is)
Computes the MD5 hash of the data in the given input stream and returns
it as a hex string.
|
static URL |
convertRequestToUrl(Request<?> request)
Converts the specified request object into a URL, containing all the
specified parameters, the specified request endpoint, etc.
|
static void |
downloadObjectToFile(NOSObject Object,
File destinationFile)
Downloads an Object, as returned from
NosClient.getObject(com.netease.cloud.services.nos.model.GetObjectRequest)
, to the specified file. |
static String |
formatIso8601Date(Date date) |
static String |
formatRfc822Date(Date date) |
static String |
formatRfc822DateShangHai(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 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.
|
static String |
urlEncode(String s)
URL encodes the specified string and returns it.
|
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 byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException
is
- NoSuchAlgorithmException
IOException
public static byte[] computeMD5Hash(byte[] data) throws NoSuchAlgorithmException, IOException
data
- NoSuchAlgorithmException
IOException
public static String removeQuotes(String s)
s
- The string to check for surrounding quotes.public static String urlEncode(String s)
s
- The string to URL encode.public static URL convertRequestToUrl(Request<?> request)
request
- The request to convert into a URL.ClientException
- 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(NOSObject Object, File destinationFile)
NosClient.getObject(com.netease.cloud.services.nos.model.GetObjectRequest)
, to the specified file.Object
- The Object containing a reference to an InputStream containing
the object's data.destinationFile
- The file to store the object's data in.Copyright © 2017. All Rights Reserved.