amazon s3 – copy large file from AWS S3 using AWS SDK for java
I am using AWS SDK 1.12.668 for java to copy files from S3 bucket. I am copying the files to a different cloud. After the copying to other cloud is done, the file is tagged as copied. I face an exception in getS3Object for large files like 3 GB files.
try {
S3Object s3Object = s3Service.getS3Object(s3ObjectId);
long objectSize = s3Object.getObjectMetadata().getContentLength();
//copy to other cloud
} catch (Exception e) {
//exception handling
}
The exception is:
org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 3,221,225,472; received: 5,406,600)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:180)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:180)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.util.LengthCheckInputStream.read(LengthCheckInputStream.java:107)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.services.s3.internal.S3AbortableInputStream.read(S3AbortableInputStream.java:125)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:106)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.chunkInputStream(LargeFileUploadTask.java:277)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.uploadSlice(LargeFileUploadTask.java:201)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:128)
Read more here: Source link
