com.amazonaws.SdkClientException: Unable to execute HTTP request

做录音上传到AmazonS3云服务器上有一段时间了,遇到这个问题归纳起来见过两次。一次是用AmazonS3测试环境下的配置去进行上传,结果失败;这次是把项目部署测试环境上,运行代码时结果失败。两次的原因细节上不同,虽然都归结于权限问题。报错信息大致相同~

下面是报错信息:

com.amazonaws.SdkClientException: Unable to execute HTTP request: life.hcp.group.taikang.com
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1069)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1035)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4169)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4116)
    at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1700)
    at com.taikang.ts.service.OutsourcingBusinessService.sftpUploadToAmazonS3(OutsourcingBusinessService.java:244)
    at com.taikang.ts.service.OutsourcingBusinessService.handelTask(OutsourcingBusinessService.java:105)
    at com.taikang.ts.service.OutsourcingBusinessService$$FastClassBySpringCGLIB$$63fe3d27.invoke()
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.j

原因分析:
出现这个Unable to execute HTTP request 问题,一般为网路不通导致。
一个是你要上传代码的这台机器的ip没有权限,一个是你的机器域名不能解析正确,导致这个请求失败。
像亚马逊这个云服务本身是要钱的,不是谁都能随随便便连上,往上扔东西。。。,你买了人家的服务,人家才会给你一套配置来连接。一般包括:endpoint , accesskey , secretkey, bucketName这四个。就像你获取数据源一样需要用户名密码啥的一样,有了这,还要一套域名解析,把你加进去,你的Ip才能正确解析,请求才是有效的(个人理解,因为这个公司内部别的部门负责,我接触不到。。。)。所以剩下的就是申请权限吧~

你可能感兴趣的:(文件操作)