use of com.aliyun.oss.model.GetObjectRequest in project alluxio by Alluxio.
the class OSSInputStream method createStream.
@Override
protected InputStream createStream(long startPos, long endPos) throws IOException {
GetObjectRequest req = new GetObjectRequest(mBucketName, mKey);
// OSS returns entire object if we read past the end
req.setRange(startPos, endPos < mContentLength ? endPos - 1 : mContentLength - 1);
OSSObject ossObject = mOssClient.getObject(req);
return new BufferedInputStream(ossObject.getObjectContent());
}
use of com.aliyun.oss.model.GetObjectRequest in project hadoop by apache.
the class AliyunOSSFileSystemStore method retrieve.
/**
* Retrieve a part of an object.
*
* @param key the object name that is being retrieved from the Aliyun OSS.
* @param byteStart start position.
* @param byteEnd end position.
* @return This method returns null if the key is not found.
*/
public InputStream retrieve(String key, long byteStart, long byteEnd) {
try {
GetObjectRequest request = new GetObjectRequest(bucketName, key);
request.setRange(byteStart, byteEnd);
return ossClient.getObject(request).getObjectContent();
} catch (OSSException | ClientException e) {
return null;
}
}
Aggregations