Quick revision
The short answer
I would use multipart upload through S3TransferManager on top of the CRT-based S3AsyncClient, which streams the file from disk in parts, uploads parts in parallel and retries failed parts, so memory stays bounded far below 1 GB. Parts must be at least 5 MB except the last and an object can have at most 10,000 parts, so for 20 GB a part size of 16 MB gives about 1,280 parts. I would track progress with a TransferListener, resume interrupted uploads without re-sending completed parts, set timeouts and retries, and in the bucket add an AbortIncompleteMultipartUpload lifecycle rule, checksums and server-side encryption; presigned multipart uploads let clients send directly to S3 instead.
What to remember
In this answer, we saw how to upload 20 GB files from a 1 GB container. Multipart upload through S3TransferManager on the CRT-based S3AsyncClient streams the file from disk in parts, uploads them in parallel and retries failed parts. The part limits of 5 MB minimum and 10,000 parts mean 16 MB parts give about 1,280 parts with bounded memory. A TransferListener tracks progress, paused uploads can resume with only the missing parts, and the bucket needs an AbortIncompleteMultipartUpload rule, checksums and encryption; presigned multipart uploads let clients bypass the service entirely.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would use multipart upload through S3TransferManager on top of the CRT-based S3AsyncClient, which streams the file from disk in parts, uploads parts in parallel and retries failed parts, so memory stays bounded far below 1 GB. Parts must be at least 5 MB except the last and an object can have at most 10,000 parts, so for 20 GB a part size of 16 MB gives about 1,280 parts. I would track progress with a TransferListener, resume interrupted uploads without re-sending completed parts, set timeouts and retries, and in the bucket add an AbortIncompleteMultipartUpload lifecycle rule, checksums and server-side encryption; presigned multipart uploads let clients send directly to S3 instead.
Why this question is asked
Large uploads break every assumption that works for small files. A 20 GB file cannot be loaded into a 1 GB container, a single HTTP request that runs for many minutes will eventually hit a network blip, and an upload that fails at 90 percent should not start again from zero. Interviewers use it to test how well we know S3 and the SDK's transfer tools. In this answer, we will recap multipart upload, size the parts, implement the upload with the Transfer Manager, handle progress and failures, configure the bucket, and look at uploading directly from clients.
1A Quick Recap of Multipart Upload
A normal PutObject sends the whole object in one HTTP request, which S3 limits to 5 GB, so a 20 GB video cannot be uploaded that way at all. Multipart upload splits the object into parts. We start an upload and receive an upload id, send each part separately with its part number, possibly in parallel and in any order, and finally ask S3 to complete the upload, at which point S3 assembles the parts into one object. If a part fails, only that part is sent again.
Until the upload is completed or aborted, S3 keeps the uploaded parts and charges for their storage, even though no object is visible in the bucket. That detail matters later for the bucket configuration.
7 messages in order. Play them, or step through them one at a time.
Each part is independent, so a failure costs one part, not the whole file.
2Sizing the Parts
S3 has three limits that shape the part size: each part except the last must be at least 5 MB, a part can be at most 5 GB, and an upload can have at most 10,000 parts. For a 20 GB file, 10,000 parts would mean about 2 MB each, which is below the minimum, so the 5 MB minimum is the binding rule and any size from 5 MB upwards works. Larger parts mean fewer requests; smaller parts mean less to re-send when one fails and less memory per part in flight.
Notice the memory line: with 8 parts in flight at 16 MB, buffers need on the order of 128 MB, which fits comfortably in a 1 GB container next to the JVM heap. The CRT client uses native memory for these buffers, outside the Java heap, so the heap must be sized to leave room for them.
3Implementing the Upload With the Transfer Manager
We do not need to write the multipart protocol ourselves. S3TransferManager, in the s3-transfer-manager module, does it on top of an S3AsyncClient. Built on the CRT-based client, created with S3AsyncClient.crtBuilder(), it splits the file into parts, reads each part from disk as it is needed, uploads parts in parallel over several connections and retries failed parts. The file is never loaded into memory as a whole.
The names of some builder options differ between SDK versions, so check your version. The ETag ending in -1280 is how S3 marks an object assembled from 1,280 parts.
4Progress, Timeouts and Resuming
A 20 GB upload can take many minutes, so we want visibility and a way to continue after interruptions. A TransferListener receives events as bytes are sent. Retries handle short network errors at the part level, and timeouts should be set per request, not for the whole transfer, because the whole transfer legitimately takes a long time.
If the process itself stops, for example because the pod is redeployed, the Transfer Manager can pause an upload and give us a ResumableFileUpload that records the upload id and the file. We can save it to disk or a database and later resume, and the Transfer Manager uploads only the parts that S3 has not already received.
Notice that the state file and the video must live on a volume that survives the restart, otherwise there is nothing to resume from. Pause and resume support depends on the client type, so check your version.
5Configuring the Bucket
Failures leave behind incomplete uploads whose parts S3 keeps storing and charging for, invisibly. A lifecycle rule with AbortIncompleteMultipartUpload cleans them up automatically after a set number of days. One day is a common choice when uploads finish within hours; it should be longer than any upload we might still resume.
For integrity, we ask the SDK to compute a checksum, such as CRC32 or CRC32C, for each part, and S3 verifies it on arrival, so a corrupted part is rejected and retried rather than stored. Recent SDK versions calculate a checksum for uploads by default; check your version. For confidentiality, the bucket enforces server-side encryption, with S3-managed keys or KMS keys, through default bucket encryption, and blocks public access.
6Letting Clients Upload Directly to S3
If the videos come from users' browsers or mobile apps, sending them through our service means every byte crosses our network twice and ties up a container for the whole transfer. With presigned multipart uploads, the service starts the multipart upload, creates presigned URLs for each part with S3Presigner.presignUploadPart, and the client uploads parts straight to S3. When the client reports the part ETags, the service completes the upload.
7Follow-up questions
Why might clients upload directly to S3 instead of through your service?
Because the service then does not carry the data. With presigned URLs, S3 receives the data directly and scales the transfer itself, while the service only authorises the upload, signs URLs and completes it. That lowers cost and memory use and avoids gateway and load balancer timeouts on long requests. The trade-offs are more logic in the client, which must split the file and upload parts, and the need to validate the finished object, for example with an S3 event that triggers a check.
What happens if CompleteMultipartUpload is never called?
No object appears in the bucket, but the uploaded parts remain and are billed as storage until the upload is aborted. That is exactly what the AbortIncompleteMultipartUpload lifecycle rule cleans up.
8Conclusion
In this answer, we saw how to upload 20 GB files from a 1 GB container. Multipart upload through S3TransferManager on the CRT-based S3AsyncClient streams the file from disk in parts, uploads them in parallel and retries failed parts. The part limits of 5 MB minimum and 10,000 parts mean 16 MB parts give about 1,280 parts with bounded memory. A TransferListener tracks progress, paused uploads can resume with only the missing parts, and the bucket needs an AbortIncompleteMultipartUpload rule, checksums and encryption; presigned multipart uploads let clients bypass the service entirely.
Open with
A 20 GB file can't go in one PutObject, which tops out at 5 GB, and it can't be loaded into a 1 GB container, so I would use multipart upload through the SDK 2.x S3TransferManager on the CRT-based S3AsyncClient.
Then, if they want more
It reads the file from disk part by part, uploads several parts in parallel and retries only the parts that fail.
Parts must be at least 5 MB except the last, with at most 10,000 per object, so for 20 GB I would pick something like 16 MB parts, about 1,280 of them, and cap concurrency at around 8, which keeps buffers near 128 MB. The CRT client uses native memory for those buffers, so I leave room outside the heap.
I would attach a TransferListener to publish progress, set per-request timeouts and a retry count, and handle restarts by pausing the upload, saving the ResumableFileUpload state to a persistent volume, and resuming later so only missing parts are sent.
On the bucket I would add a lifecycle rule AbortIncompleteMultipartUpload after one day, because abandoned parts keep costing storage without showing up as objects. I would also request checksums like CRC32C so corrupted parts are rejected, and enforce server-side encryption and block public access.
If the files come from users' devices, I would rather have clients upload directly to S3 with presigned multipart URLs, so the service only authorises and completes the upload and doesn't carry 20 GB through its own network.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- AWS documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A Java service must upload video files of up to 20 GB to S3 from a container with 1 GB...": https://scrivio-interview-library.netlify.app/spring-boot/aws/e1448c4449/