当前位置: 首页>>代码示例>>Java>>正文


Java AmazonS3Exception.setServiceName方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.model.AmazonS3Exception.setServiceName方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3Exception.setServiceName方法的具体用法?Java AmazonS3Exception.setServiceName怎么用?Java AmazonS3Exception.setServiceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.model.AmazonS3Exception的用法示例。


在下文中一共展示了AmazonS3Exception.setServiceName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPdf

import com.amazonaws.services.s3.model.AmazonS3Exception; //导入方法依赖的package包/类
@Override
public InputStream getPdf(final String paperId) throws IOException {
    // We download to a temp file first. If we gave out an InputStream that comes directly from
    // S3, it would time out if the caller of this function reads the stream too slowly.
    final String key = paperId.substring(0, 4) + "/" + paperId.substring(4) + ".pdf";
    final S3Object object;
    try {
        object = s3.getObject(bucket, key);
    } catch(final AmazonS3Exception e) {
        final AmazonS3Exception rethrown =
                new AmazonS3Exception(
                        String.format(
                                "Error for key s3://%s/%s",
                                bucket,
                                key),
                        e);
        rethrown.setExtendedRequestId(e.getExtendedRequestId());
        rethrown.setErrorCode(e.getErrorCode());
        rethrown.setErrorType(e.getErrorType());
        rethrown.setRequestId(e.getRequestId());
        rethrown.setServiceName(e.getServiceName());
        rethrown.setStatusCode(e.getStatusCode());
        throw rethrown;
    }

    final Path tempFile = Files.createTempFile(paperId + ".", ".paper.pdf");
    try {
        Files.copy(object.getObjectContent(), tempFile, StandardCopyOption.REPLACE_EXISTING);
        return new BufferedInputStream(Files.newInputStream(tempFile));
    } finally {
        Files.deleteIfExists(tempFile);
    }
}
 
开发者ID:allenai,项目名称:science-parse,代码行数:34,代码来源:ScholarBucketPaperSource.java

示例2: buildException

import com.amazonaws.services.s3.model.AmazonS3Exception; //导入方法依赖的package包/类
private static AmazonS3Exception buildException(
        String message, String errorCode, int statusCode, Map<String, String> additionalDetails
) {
    AmazonS3Exception exception = newException(message, errorCode, statusCode, additionalDetails);
    exception.setServiceName(S3_SERVICE_DISPLAY_NAME);
    return exception;
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:8,代码来源:S3ExceptionBuilder.java

示例3: build

import com.amazonaws.services.s3.model.AmazonS3Exception; //导入方法依赖的package包/类
public AmazonS3Exception build() {
	AmazonS3Exception result = new AmazonS3Exception(message);

	result.setStatusCode(statusCode);
	result.setErrorCode(errorCode);
	result.setRequestId(requestId);
	result.setServiceName(SERVICE_NAME);

	return result;
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:11,代码来源:AmazonS3ExceptionBuilder.java


注:本文中的com.amazonaws.services.s3.model.AmazonS3Exception.setServiceName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。