本文整理匯總了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);
}
}
示例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;
}
示例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;
}