本文整理汇总了Java中org.jets3t.service.model.S3Object.getDataInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java S3Object.getDataInputStream方法的具体用法?Java S3Object.getDataInputStream怎么用?Java S3Object.getDataInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jets3t.service.model.S3Object
的用法示例。
在下文中一共展示了S3Object.getDataInputStream方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
try {
final HttpRange range = HttpRange.withStatus(status);
final RequestEntityRestStorageService client = session.getClient();
final S3Object object = client.getVersionedObject(
file.attributes().getVersionId(),
containerService.getContainer(file).getName(),
containerService.getKey(file),
null, // ifModifiedSince
null, // ifUnmodifiedSince
null, // ifMatch
null, // ifNoneMatch
status.isAppend() ? range.getStart() : null,
status.isAppend() ? (range.getEnd() == -1 ? null : range.getEnd()) : null);
if(log.isDebugEnabled()) {
log.debug(String.format("Reading stream with content length %d", object.getContentLength()));
}
return object.getDataInputStream();
}
catch(ServiceException e) {
throw new S3ExceptionMappingService().map("Download {0} failed", e, file);
}
}
示例2: retrieve
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
/**
*
* @param key
* The key is the object name that is being retrieved from the S3 bucket
* @return
* This method returns null if the key is not found
* @throws IOException
*/
@Override
public InputStream retrieve(String key, long byteRangeStart)
throws IOException {
try {
LOG.debug("Getting key: {} from bucket: {} with byteRangeStart: {}",
key, bucket.getName(), byteRangeStart);
S3Object object = s3Service.getObject(bucket, key, null, null, null,
null, byteRangeStart, null);
return object.getDataInputStream();
} catch (ServiceException e) {
handleException(e, key);
return null;
}
}
示例3: createDownloader
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private Callable<Path> createDownloader(final int retryNum) {
return new Callable<Path>() {
public Path call() throws Exception {
final Path chunkPath = (chunk == 0) ? downloadTo : Paths.get(downloadTo + "_" + chunk + "_" + retryNum);
chunkPath.toFile().deleteOnExit();
final long startTime = System.currentTimeMillis();
final long byteRangeStart = chunk * chunkSize;
final long byteRangeEnd = Math.min((chunk + 1) * chunkSize - 1, length);
log.info("Downloading {} - chunk {} (retry {}) ({}-{}) to {}", s3Artifact.getFilename(), chunk, retryNum, byteRangeStart, byteRangeEnd, chunkPath);
S3Object fetchedObject = s3.getObject(s3Artifact.getS3Bucket(), s3Artifact.getS3ObjectKey(), null, null, null, null, byteRangeStart, byteRangeEnd);
try (InputStream is = fetchedObject.getDataInputStream()) {
Files.copy(is, chunkPath, StandardCopyOption.REPLACE_EXISTING);
}
log.info("Finished downloading chunk {} (retry {}) of {} ({} bytes) in {}", chunk, retryNum, s3Artifact.getFilename(), byteRangeEnd - byteRangeStart, JavaUtils.duration(startTime));
return chunkPath;
};
};
}
示例4: retrieve
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public InputStream retrieve(String key, long byteRangeStart)
throws IOException {
try {
S3Object object = s3Service.getObject(bucket, key, null, null, null,
null, byteRangeStart, null);
return object.getDataInputStream();
} catch (S3ServiceException e) {
if ("NoSuchKey".equals(e.getS3ErrorCode())) {
return null;
}
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new S3Exception(e);
}
}
示例5: get
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private InputStream get(String key, boolean checkMetadata)
throws IOException {
try {
S3Object object = s3Service.getObject(bucket, key);
if (checkMetadata) {
checkMetadata(object);
}
return object.getDataInputStream();
} catch (S3ServiceException e) {
if ("NoSuchKey".equals(e.getS3ErrorCode())) {
return null;
}
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new S3Exception(e);
}
}
示例6: retrieve
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
/**
*
* @param key
* The key is the object name that is being retrieved from the S3 bucket
* @return
* This method returns null if the key is not found
* @throws IOException
*/
@Override
public InputStream retrieve(String key, long byteRangeStart)
throws IOException {
try {
if(LOG.isDebugEnabled()) {
LOG.debug("Getting key: " + key + " from bucket:" + bucket.getName() + " with byteRangeStart: " + byteRangeStart);
}
S3Object object = s3Service.getObject(bucket, key, null, null, null,
null, byteRangeStart, null);
return object.getDataInputStream();
} catch (ServiceException e) {
handleServiceException(key, e);
return null; //return null if key not found
}
}
示例7: getDirectReadableChannel
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
protected ReadableByteChannel getDirectReadableChannel() throws ContentIOException {
try {
// Confirm the requested object exists
if (!exists()) {
throw new ContentIOException("Content object does not exist");
}
if(LOG.isDebugEnabled()){
LOG.debug("S3ContentReader Obtaining Input Stream: nodeUrl="+nodeUrl);
}
// Get the object and retrieve the input stream
final S3Object object = s3Service.getObject(bucket, nodeUrl);
ReadableByteChannel channel = null;
final InputStream is = object.getDataInputStream();
channel = Channels.newChannel(is);
if(LOG.isDebugEnabled()){
LOG.debug("S3ContentReader Success Obtaining Input Stream: nodeUrl="+nodeUrl);
}
return channel;
} catch (Exception excp) {
throw new ContentIOException("Failed to open channel: " + this, excp);
}
}
开发者ID:abhinavmishra14,项目名称:alfresco-amazon-s3-content-store-integration,代码行数:24,代码来源:S3ContentReader.java
示例8: get
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private InputStream get(String key) throws IOException {
try {
S3Object object = s3Service.getObject(bucket, key);
return object.getDataInputStream();
} catch (S3ServiceException e) {
if ("NoSuchKey".equals(e.getS3ErrorCode())) {
return null;
}
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new S3Exception(e);
}
}
示例9: retrieve
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public InputStream retrieve(String key) throws IOException {
try {
S3Object object = s3Service.getObject(bucket, key);
return object.getDataInputStream();
} catch (S3ServiceException e) {
handleServiceException(key, e);
return null; //never returned - keep compiler happy
}
}
示例10: getFile
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public InputStream getFile(String path) throws IOException {
try {
path = stripLeadingSlash(path);
S3Object object = service.getObject(bucketName, path);
return object.getDataInputStream();
} catch (ServiceException e) {
throw new IOException(e);
}
}
示例11: get
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private InputStream get(String key, long byteRangeStart) throws IOException {
try {
S3Object object = s3Service.getObject(bucket, key, null, null, null,
null, byteRangeStart, null);
return object.getDataInputStream();
} catch (S3ServiceException e) {
if ("NoSuchKey".equals(e.getS3ErrorCode())) {
return null;
}
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new S3Exception(e);
}
}
示例12: makeObjects
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
void makeObjects()
throws IOException, URISyntaxException, ServiceException, NoSuchAlgorithmException {
// Configure the service
S3Service s3Service = testUtil.configureS3Service(hostName, PROXY_PORT);
// Prepare objects inside MasterBucket; PUT and READ
int randInt = Math.abs(new Random().nextInt() % 10) + 2;
for (int i = 0; i < randInt; i++) {
String oid = (useMasterObject) ? masterObjectName :
"object_" + id + "_" + i;
byte[] data = new byte[SMALL_SIZE];
for (int d = 0; d < SMALL_SIZE; d++) {
data[i] = (byte) (d % 256);
}
S3Object s3Object = new S3Object(oid, data);
s3Service.putObject(masterBucket, s3Object);
S3Object object =
s3Service.getObject(masterBucket, s3Object.getKey());
InputStream dataInputStream = object.getDataInputStream();
for (int j = 0; j < SMALL_SIZE; j++) {
int read = dataInputStream.read();
if (read == -1) fail();
}
assertEquals(-1, dataInputStream.read());
dataInputStream.close();
}
// Shutdown the service
s3Service.shutdown();
passed = true;
}
示例13: retrieve
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public InputStream retrieve(String key) throws IOException {
try {
S3Object object = s3Service.getObject(bucket, key);
return object.getDataInputStream();
} catch (S3ServiceException e) {
if ("NoSuchKey".equals(e.getS3ErrorCode())) {
return null;
}
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new S3Exception(e);
}
}
示例14: run
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public void run() {
try {
log.info("Retrieving "
+ object.getKey()
+ ", ("
+ i
+ "/"
+ length
+ ") "
+ CSVExport.humanReadableByteCount(
object.getContentLength(), false));
// now really download the file
S3Object dataObject = getStorage().getObject(resultBucket,
object.getKey());
// data file
if (object.getKey().endsWith(".nq.gz")) {
BufferedReader retrievedDataReader = new BufferedReader(
new InputStreamReader(new GZIPInputStream(
dataObject.getDataInputStream())));
String line;
while ((line = retrievedDataReader.readLine()) != null) {
Line l = parseLine(line);
if (l == null) {
continue;
}
OutputStream out = getOutput(l.extractor, dataDir,
sizeLimitMb);
out.write(new String(l.quad + "\n").getBytes());
}
retrievedDataReader.close();
}
} catch (Exception e) {
log.warn("Error in " + object.getKey(), e);
} finally {
setChanged();
notifyObservers();
}
}