本文整理汇总了Java中org.jets3t.service.model.StorageObject.closeDataInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java StorageObject.closeDataInputStream方法的具体用法?Java StorageObject.closeDataInputStream怎么用?Java StorageObject.closeDataInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jets3t.service.model.StorageObject
的用法示例。
在下文中一共展示了StorageObject.closeDataInputStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveMetadata
import org.jets3t.service.model.StorageObject; //导入方法依赖的package包/类
@Override
public FileMetadata retrieveMetadata(String key) throws IOException {
StorageObject object = null;
try {
LOG.debug("Getting metadata for key: {} from bucket: {}",
key, bucket.getName());
object = s3Service.getObjectDetails(bucket.getName(), key);
return new FileMetadata(key, object.getContentLength(),
object.getLastModifiedDate().getTime());
} catch (ServiceException e) {
try {
// process
handleException(e, key);
return null;
} catch (FileNotFoundException fnfe) {
// and downgrade missing files
return null;
}
} finally {
if (object != null) {
object.closeDataInputStream();
}
}
}
示例2: retrieveMetadata
import org.jets3t.service.model.StorageObject; //导入方法依赖的package包/类
@Override
public FileMetadata retrieveMetadata(String key) throws IOException {
StorageObject object = null;
try {
if(LOG.isDebugEnabled()) {
LOG.debug("Getting metadata for key: " + key + " from bucket:" + bucket.getName());
}
object = s3Service.getObjectDetails(bucket.getName(), key);
return new FileMetadata(key, object.getContentLength(),
object.getLastModifiedDate().getTime());
} catch (ServiceException e) {
// Following is brittle. Is there a better way?
if ("NoSuchKey".equals(e.getErrorCode())) {
return null; //return null if key not found
}
handleServiceException(e);
return null; //never returned - keep compiler happy
} finally {
if (object != null) {
object.closeDataInputStream();
}
}
}
示例3: putObjectWithRequestEntityImpl
import org.jets3t.service.model.StorageObject; //导入方法依赖的package包/类
protected void putObjectWithRequestEntityImpl(String bucketName, StorageObject object,
HttpEntity requestEntity, Map<String, String> requestParams) throws ServiceException
{
Map<String, Object> map = createObjectImpl(bucketName, object.getKey(),
object.getContentType(), requestEntity, object.getMetadataMap(),
requestParams, object.getAcl(), object.getStorageClass(),
object.getServerSideEncryptionAlgorithm());
try {
object.closeDataInputStream();
} catch (IOException e) {
if (log.isWarnEnabled()) {
log.warn("Unable to close data input stream for object '" + object.getKey() + "'", e);
}
}
// Populate object with result metadata.
object.replaceAllMetadata(map);
// Confirm that the data was not corrupted in transit by checking S3's calculated
// hash value with the locally computed value. This is only necessary if the user
// did not provide a Content-MD5 header with the original object.
// Note that we can only confirm the data if we used a RepeatableRequestEntity to
// upload it, if the user did not provide a content length with the original
// object we are SOL.
boolean md5Verify = isLiveMD5HashingRequired(object)
&& requestEntity instanceof RepeatableRequestEntity;
if (log.isTraceEnabled()) {
log.trace("Will " + (md5Verify ? "" : "NOT ")
+ "verify expected and actual e-tag values.");
}
if (md5Verify) {
// Obtain locally-calculated MD5 hash from request entity.
String hexMD5OfUploadedData = ServiceUtils.toHex(
((RepeatableRequestEntity)requestEntity).getMD5DigestOfData());
verifyExpectedAndActualETagValues(hexMD5OfUploadedData, object);
}
}