Skip to content

Presigned-URL support (url_for) + honor path prefix in standard flow (#7)#8

Merged
thorwhalen merged 1 commit into
masterfrom
feat/presigned-url-7
Jun 20, 2026
Merged

Presigned-URL support (url_for) + honor path prefix in standard flow (#7)#8
thorwhalen merged 1 commit into
masterfrom
feat/presigned-url-7

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Closes #7.

What

  • url_for(key, *, expires_in=3600, client_method='get_object', **params) on the S3 bucket stores — returns a presigned URL via the boto3 client (prefix-aware override on S3BucketReader). Lets a caller 302-redirect so the object store serves bytes + HTTP Range directly, off the app process. Works for any S3-compatible endpoint (AWS / R2 / MinIO / Supabase) — pure client call, no object fetch.
  • Bug fix: S3Store(path=...) (documented as the key prefix) was silently dropped in the standard AWS flow — only the Supabase / skip-check branches honored it. Now applied there too.
  • Tests: test_url_for.py, moto-based so they run anywhere (no real S3). An autouse fixture clears AWS_ENDPOINT_URL because test_base sets it (localstack) via os.environ without cleanup, leaking across the suite.

First customer

lacing's ArtifactStore.blob_location (reelee storage migration → S3, reelee#134): it probes the blob backend for url_for and 302-redirects when present.

Note

The localstack-parametrized tests in test_base/test_store fail without a running localstack server (pre-existing/environmental). Making them skip-when-unreachable + use monkeypatch for env is a separate test-hygiene follow-up.

https://claude.ai/code/session_01NLg6gmcHzRiDviqdgyooZk

… flow (#7)

- Add `url_for(key, *, expires_in=3600, client_method='get_object', **params)`
  to the S3 bucket stores (BaseS3BucketReader + prefix-aware S3BucketReader
  override). Returns a presigned URL via the boto3 client — lets a caller
  302-redirect so the object store serves bytes + HTTP Range directly, off the
  app process. Works for any S3-compatible endpoint (AWS, R2, MinIO, Supabase).
  First customer: lacing.ArtifactStore.blob_location (reelee storage migration).

- Fix: S3Store's `path=` (documented as the key prefix) was silently DROPPED in
  the standard AWS flow — only the Supabase / skip-check branches honored it.
  Now applied there too (normalized like S3BucketReader.__post_init__).

- Add moto-based tests (test_url_for.py) — run anywhere, no real S3. An autouse
  fixture clears AWS_ENDPOINT_URL because test_base sets it (localstack) via
  os.environ without cleanup, which otherwise leaks across the suite.

Note: the localstack-parametrized tests in test_base/test_store fail without a
running localstack server (pre-existing/environmental); making them skip-when-
unreachable + use monkeypatch for env is a separate test-hygiene follow-up.

Claude-Session: https://claude.ai/code/session_01NLg6gmcHzRiDviqdgyooZk
@thorwhalen thorwhalen merged commit ec01a3f into master Jun 20, 2026
4 of 6 checks passed
@thorwhalen thorwhalen deleted the feat/presigned-url-7 branch June 20, 2026 09:44
thorwhalen added a commit to thorwhalen/lacing that referenced this pull request Jun 20, 2026
…elee#134)

ArtifactStore.from_s3(bucket, *, catalog=None, prefix=None, **s3_kwargs) wires
an S3-compatible object store (AWS / R2 / MinIO / Supabase) as the `blobs`
backend via s3dol — pure DI, the facade + all callers unchanged. Content-
addressed blobs are a natural fit (flat, immutable, dedup, forever-cacheable).
blob_location (Phase 0) returns a presigned GET URL via s3dol's new url_for, so
the serving layer can 302-redirect and let the store deliver bytes + Range
directly. s3dol imported lazily; the catalog defaults to in-memory (Phase 2
adds the Postgres catalog).

Tests: tests/test_artifact_store_s3.py — moto-mocked (no real S3, runs in CI):
content-addressed roundtrip, presigned-URL blob_location (+ blob_path None for
object stores), missing-blob None, dual-write save, key-prefix. An autouse
fixture clears AWS endpoint env so @mock_aws always intercepts.

pyproject: dev extra gains `s3dol` + `moto[s3]`; new `s3` extra (s3dol). Needs
s3dol's url_for (i2mint/s3dol#8) on master before this ships.

Claude-Session: https://claude.ai/code/session_01NLg6gmcHzRiDviqdgyooZk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add presigned-URL support (url_for) to S3 bucket stores

1 participant