Documentation
¶
Overview ¶
Package images is the gateway-side presign service for user image uploads: its own blobstore.Storage (its own bucket) and its own /v1/images route, built on pkg/blobstore.
Flow (see the project plan): the client asks for an upload slot and gets a presigned PUT URL plus a presigned GET URL; it uploads the bytes, then sends the GET URL inside its chat message. The credential-free sprite downloads via the GET URL and inlines the image into the agent — the gateway never sees the bytes.
Index ¶
Constants ¶
const DefaultPresignTTL = 30 * time.Minute
DefaultPresignTTL is how long image presigned URLs stay valid when Config.PresignTTL is zero. Longer than sync's 5m default because the GET URL is minted at upload time and must outlive the user composing and sending the message.
Variables ¶
var AllowedMimes = map[string]bool{ "image/png": true, "image/jpeg": true, "image/webp": true, "image/gif": true, }
AllowedMimes is the closed set of accepted image content types — the formats Claude and OpenCode both take as vision input. A closed set (not a prefix check) stops the presign endpoint from minting upload slots for arbitrary content.
Functions ¶
func KeyForImage ¶
KeyForImage builds the storage key for a user's uploaded image:
<userID>/images/<imageID>
Images live in a dedicated bucket (separate from sync), so the prefix is tenant-scoping/defense-in-depth rather than collision avoidance. userID MUST come from authenticated token claims; imageID is a server-minted ULID. Both are validated for path safety.
Types ¶
type Config ¶
type Config struct {
// Storage is the object store images live in — its own dedicated
// bucket. Required.
Storage blobstore.Storage
// PresignTTL overrides DefaultPresignTTL when non-zero.
PresignTTL time.Duration
}
Config wires a Server.