【以下的问题经过翻译处理】 处理过程以异常结束,并显示以下错误信息:“您的套接字连接未在超时时间内进行读取或写入。空闲连接将被关闭。(服务:S3,状态码:400,“正在尝试上传的文件大小为3GB。 运行了四次。第一次在大约35%停止,但是最后三次在50.1%处停止。这是代码和gradle文件。
、、、
S3AsyncClient s3AsyncClient;
S3TransferManager transferManager;
public S3Upload() {
s3AsyncClient =
S3AsyncClient.crtBuilder()
.credentialsProvider(DefaultCredentialsProvider.create())
.region(Region.US_EAST_1)
.targetThroughputInGbps(20.0)
.minimumPartSizeInBytes(8 * MB)
.build();
transferManager =
S3TransferManager.builder()
.s3Client(s3AsyncClient)
.build();
}
public void writeFileToS3(String bucketName, String fileName,String filePath) {
UploadFileRequest uploadFileRequest =
UploadFileRequest.builder()
.putObjectRequest(b -> b.bucket(bucketName).key(fileName))
.addTransferListener(LoggingTransferListener.create())
.source(Paths.get(filePath))
.build();
FileUpload fileUpload = transferManager.uploadFile(uploadFileRequest);
CompletedFileUpload uploadResult = fileUpload.completionFuture().join();
System.out.println(uploadResult);
}
public static void main(String [] args)
{
S3Upload fileUpload = new S3Upload();
String bucket = args[0];
String destFile = args[1];
String srcFile = args[2];
System.out.println("Start date and time: " + LocalDateTime.now().toString());
fileUpload.writeFileToS3(bucket, destFile, srcFile);
System.out.println("End date and time: " + LocalDateTime.now().toString());
}
plugins {
id 'java'
}
、、、
、、、
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation platform('software.amazon.awssdk:bom:2.20.56')
implementation 'software.amazon.awssdk:s3'
implementation 'software.amazon.awssdk:s3-transfer-manager'
implementation 'software.amazon.awssdk.crt:aws-crt:0.21.14'
implementation 'org.slf4j:slf4j-api:'
implementation 'org.slf4j:slf4j-simple:2.0.6'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
test {
useJUnitPlatform()
、、、