The instance-wide maximum upload size in the storage setting and the per-user UPLOAD_BYTES usage limit were two caps on the same thing, with a rule that the per-user value could only lower the instance value. The storage setting field is removed, and the all-users UPLOAD_BYTES usage limit is the only per-file cap. A user's own limit replaces the default in either direction, and no limit means any file size. - Remove upload_size_limit_mb from the API and store storage settings, the 32 MiB store default, and the deployment config check. - Drop the FILE_TOO_LARGE error; every refusal is QUOTA_EXCEEDED with metric UPLOAD_BYTES. - Split usagelimit.CheckFileSize out of CheckUpload and call it from memo import, so import is no longer a bypass. - Remove the Maximum upload size field from the Storage section and the instance-limit warning from the usage limits dialog. The old value is not carried over. Instances that relied on the default accept any file size until an admin sets a limit.
Fileserver Package
The fileserver package serves binary content (attachments, avatars) over plain HTTP instead of gRPC, so that HTTP range requests work — required for Safari video/audio playback (RFC 9110 §14). Metadata stays on the gRPC API; only bytes are served here.
Endpoints
GET /file/attachments/:uid[/:filename] # attachment binary
?thumbnail=true # JPEG thumbnail for supported image types
?motion=true # embedded motion-photo video clip
?share_token={uid} # access via a memo share link
GET /file/users/:identifier/avatar # user avatar (by username)
Authentication
Handled by server/auth (see authenticator.go and token.go for the constants and token formats). Priority: Authorization: Bearer header (access token or personal access token) first, then the refresh token cookie. See getCurrentUser in fileserver.go.
Authorization
Attachment access follows memo visibility, evaluated by core/access.CheckMemoReadContext:
- Public memo: no auth required (when the instance allows anonymous access)
- Protected memo: any authenticated user
- Private memo: creator only
- Valid
share_token: grants access to that memo's attachments - Unlinked attachment (no memo): creator or admin only
Avatars are public on instances that allow anonymous access; private instances require authentication.
Serving behavior
- Video/audio are streamed with range-request support (
http.ServeFile/http.ServeContentfor local and database storage); S3-backed media is proxied with rangedGetObjectrequests. - Thumbnails are generated at max 600px, cached in
{data_dir}/.thumbnail_cache/, with a semaphore capping concurrent generation. Images with HDR/wide-gamut metadata are served as originals, since re-encoding would strip it. - Motion photos have their embedded video extracted and cached in
{data_dir}/.motion_cache/. - XSS prevention: script-capable MIME types are rewritten to
application/octet-stream, non-media files getContent-Disposition: attachment, and all responses carryX-Content-Type-Options: nosniffplus a restrictiveContent-Security-Policy. - Caching: public attachments get
public, no-cache; private onesprivate, no-store; avatars and thumbnailspublic, max-age=3600.
Testing
Unit tests live in fileserver_test.go, covering permission checks, streaming, thumbnails, and metadata detection. Manual checks:
curl "http://localhost:8081/file/attachments/{uid}/file.jpg"
curl -H "Range: bytes=0-999" "http://localhost:8081/file/attachments/{uid}/video.mp4"