public final class AliyunOSSUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
calculatePartSize(long contentLength,
long minPartSize)
Calculate a proper size of multipart piece.
|
static com.aliyun.oss.common.auth.CredentialsProvider |
getCredentialsProvider(org.apache.hadoop.conf.Configuration conf)
Create credential provider specified by configuration, or create default
credential provider if not specified.
|
static String |
getValueWithKey(org.apache.hadoop.conf.Configuration conf,
String key)
Used to get password from configuration.
|
static String |
maybeAddTrailingSlash(String key)
Turns a path (relative or otherwise) into an OSS key, adding a trailing
"/" if the path is not the root and does not already have a "/"
at the end.
|
static void |
skipFully(InputStream is,
long n)
Skip the requested number of bytes or fail if there are no enough bytes
left.
|
public static String getValueWithKey(org.apache.hadoop.conf.Configuration conf, String key) throws IOException
conf - configuration that contains password informationkey - the key of the passwordIOException - if failed to get password from configurationpublic static void skipFully(InputStream is, long n) throws IOException
InputStream.skip(long)
may not skip as many bytes as requested (most likely because of reaching
EOF).is - the input stream to skip.n - the number of bytes to skip.IOException - thrown when skipped less number of bytes.public static long calculatePartSize(long contentLength,
long minPartSize)
minPartSize
is too small, the number of multipart pieces may exceed the limit of
Constants.MULTIPART_UPLOAD_PART_NUM_LIMIT.contentLength - the size of file.minPartSize - the minimum size of multipart piece.public static com.aliyun.oss.common.auth.CredentialsProvider getCredentialsProvider(org.apache.hadoop.conf.Configuration conf)
throws IOException
conf - configurationIOException - on any problem. Class construction issues may be
nested inside the IOE.public static String maybeAddTrailingSlash(String key)
key - OSS key or ""Copyright © 2018. All Rights Reserved.