AlgoMaster Logo
AlgoMasterCoordinate a Multipart Uploadmedium

Coordinate a Multipart Upload

medium

Multipart uploads split a large object into independently retryable parts. Completion is a separate commit step that names the exact ordered parts and verifies their checksums.

Design MultipartUploadSession(int minPartSize):

  • uploadPart(partNumber, sizeBytes, checksum) stores a part. Retrying the same number replaces it. Calls after abort do nothing.
  • complete(partNumbers, checksums) returns total size, or -1 if invalid. The arrays must have equal nonzero length; part numbers must be exactly 1..n; every part and checksum must match; every part except the last must be at least minPartSize.
  • abort() clears all parts and permanently aborts the session.
Example 1:
Example 2:

Constraints

  • 1 <= minPartSize, partNumber <= 10^6
  • 0 <= sizeBytes <= 10^8; successful totals fit a signed 32-bit integer.
  • Checksums are non-empty printable ASCII strings.
  • At most 10^4 operations are performed per object.
Hints

Loading...
CallReturns
new MultipartUploadSession(5)null
uploadPart(2, 3, "b")null
uploadPart(1, 5, "a")null
complete([1,2], ["a","b"])8

Parts may arrive out of order. Part 1 meets the minimum and the smaller final part is allowed.

Run checks these cases. Submit also runs a larger hidden set.