Skip to content

Server: no way to route uploads to different buckets per request (keyStrategy doesn't see metadata) #337

Description

@BSalaeddin

We're moving an app off a hand-rolled v1 setup that routes each upload to one of three buckets (images, quarantine for unscanned docs, general documents), each with its own credentials and endpoint. The client says which class of upload it is via metadata in the presign request, and the server picks the bucket from that.

With @upupjs/server 3.1.0 this routing can't be expressed:

  • storage in UpupServerConfig is a single static object (type/bucket/region/credentials), no function form
  • keyStrategy receives { userId, fileName, contentType, size } (dist/config-28bb05f8.d.ts) — no metadata, no request
  • hooks.onBeforeUpload does get the Request, but it can only return a boolean, it can't influence where the file goes

So createUpupHandler / createUpupNextHandler only fit single-bucket apps, and we had to keep our own presign route.

Would either of these be acceptable?

  1. allow storage to be (ctx) => StorageConfig resolved per request, or
  2. pass the presign metadata (and ideally the request) into keyStrategy

Happy to test a canary against a real multi-bucket setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions