小编Vin*_*sen的帖子

AWS S3 Java SDK 上传失败并在 Groovy 中显示“连接池关闭”

我正在使用 Amazon Java SDK(在撰写本文时最新版本为 1.11.147)和 Groovy(Groovy 版本:2.4.11 JVM:1.8.0_112 供应商:Oracle Corporation OS:Mac OS X)将文件上传到 S3。使用 Amazon 文档中关于Transfer Manager 的说明,我能够将内容从一个存储桶复制到另一个存储桶。但是,上传总是失败。我尝试了以下3种方法。我让 Grapes 抓取了 httpclient 和 httpcore 的新版本,因为我在这个 Stack Overflow Post Apache PoolingHttpClientConnectionManager throwing非法状态异常中读到了什么

@Grapes([
  @Grab(group='com.amazonaws', module='aws-java-sdk', version='1.11.147'),
  // https://mvnrepository.com/artifact/org.apache.commons/commons-compress
  @Grab(group='org.apache.commons', module='commons-compress', version='1.13'),
  // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
  @Grab(group='org.apache.httpcomponents', module='httpclient', version='4.5.3'),
  // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
  @Grab(group='org.apache.httpcomponents', module='httpcore', version='4.4.6')
])

// creds is String saying which ~/.aws/credentials profile to use
def credentials = new ProfileCredentialsProvider(creds)

def s3client  = AmazonS3ClientBuilder.standard().
                withCredentials(credentials).
                withRegion(region).
                build()
def tx = TransferManagerBuilder.standard().
         withS3Client(s3client). …
Run Code Online (Sandbox Code Playgroud)

groovy amazon-s3 amazon-web-services aws-java-sdk

2
推荐指数
1
解决办法
4723
查看次数