Expose `MultipartStore`: multipart uploads that span several calls

Open
#833 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust
Domain
api, backend

Research direction

Start by reading the existing sign functions and the Rust MultipartStore trait implementations named in the issue, especially PrefixStore and MaybePrefixedStore. The proposal outlines four public functions and a MultipartCapableStore alias, but leaves names and shapes open for discussion. Done means the maintainers agree on an API and it supports creating, resuming, completing, and aborting multipart uploads across calls.

Written by the indexing model from the issue text.

Description

Use case

put(..., use_multipart=True) and open_writer run a whole multipart upload inside one call. Some callers need to keep one multipart upload open across calls, and across processes: a server that receives a large file in several HTTP requests (a resumable upload protocol such as tus, where each request can reach a different host) creates the upload once, sends part n from the request that carries those bytes, and completes it from a later request. Today this needs a second S3 client next to obstore.

object_store already has the operations in its MultipartStore trait, implemented by AmazonS3, GoogleCloudStorage, MicrosoftAzure, InMemory and PrefixStore. The upload id and the part ids are strings, so a caller can store them and resume from another process.

Proposal

Four functions in the style of sign, each with an _async twin, restricted to the stores that implement the trait:

MultipartCapableStore: TypeAlias = AzureStore | GCSStore | S3Store | MemoryStore

class PartId(TypedDict):
    content_id: str

def create_multipart(
    store: MultipartCapableStore,
    path: str,
    *,
    attributes: Attributes | None = None,
    tags: dict[str, str] | None = None,
) -> str: ...  # the upload id

def put_part(
    store: MultipartCapableStore,
    path: str,
    upload_id: str,
    part_idx: int,
    data: bytes | Buffer,
) -> PartId: ...

def complete_multipart(
    store: MultipartCapableStore,
    path: str,
    upload_id: str,
    parts: Sequence[PartId],
) -> PutResult: ...

def abort_multipart(store: MultipartCapableStore, path: str, upload_id: str) -> None: ...

On the Rust side this would be a MultipartCapableStore enum like SignCapableStore, plus a MultipartStore impl for MaybePrefixedStore that prefixes the path, as PrefixStore does. MemoryStore in the alias lets users test their code without a bucket.

Names and shapes are a suggestion. Would you accept this?

Dominant language
Python
Stars
848
Forks
50
Avg merge
7h 58m
Merged PRs (30d)
10

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/obstore

All issues in developmentseed/obstore

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.