Skip to main content

Module upload

Module upload 

Source
Expand description

Single-part and multipart upload implementation.

§Protocol

  1. Acquire a scoped resource lock via LockRegistry.
  2. tokio::fs::metadata(source_path)total_bytes.
  3. If total_bytes < 5 MB: single-part put_object path.
  4. Else: multipart path: a. create_multipart_upload → upload_id. b. Record in redb multipart_active table. c. Compute part_size = max(8 MB, total_bytes / 9999) (cap at 10 000 parts). d. Stream parts concurrently via tokio::Semaphore (default 4 in-flight). e. complete_multipart_upload → remove from multipart_active → emit objects:updated.
  5. On cancel: abort_multipart_upload, remove from table, emit Canceled.
  6. On error: same cleanup.
  7. Release lock with appropriate ReleaseReason.

§OCP contract

The lock registry, transfer registry, and progress throttle are reused from task 31 (download). No new infrastructure is introduced.

Structs§

ObjectsUpdatedPayload 🔒
Payload for the objects:updated event.

Constants§

MAX_PARTS 🔒
S3 maximum part count.
MIN_PART_SIZE 🔒
Minimum multipart part size (8 MB).
SINGLE_PART_THRESHOLD 🔒
Files smaller than this use single-part put_object.

Functions§

abort_multipart 🔒
cleanup_on_error 🔒
compute_part_size
Compute the multipart part size for a given total file size.
multipart_upload 🔒
now_ms 🔒
now_secs 🔒
single_part_upload 🔒
upload_object
Upload source_path to bucket/key.