Skip to content

Make avatar upload size limit configurable via environment variable #374

@tgoetten

Description

@tgoetten

✨ Feature Request

Is your feature request related to a problem? Please describe.

When self-hosting Kan with Docker, I'm unable to upload avatar images larger than 2MB. The error message "File too large" appears, but there is no way to configure this limit without modifying the source code and rebuilding the Docker image.

Describe the solution you'd like

Add a new environment variable (e.g., S3_AVATAR_UPLOAD_LIMIT) to make the avatar upload size limit configurable, similar to how S3_UPLOAD_LIMIT works for attachments.

The change would be in apps/web/src/pages/api/upload/avatar.ts:

// Current (hardcoded):
const MAX_SIZE_BYTES = 2 * 1024 * 1024; // 2MB

// Proposed (configurable):
const MAX_SIZE_BYTES = parseInt(process.env.S3_AVATAR_UPLOAD_LIMIT || '2097152', 10); // Default 2MB

Describe alternatives you've considered

  • Resizing images manually before uploading (inconvenient for users)
  • Building a custom Docker image with modified source code (difficult to maintain across updates)
  • Using a reverse proxy to modify request limits (doesn't solve the application-level check)

Additional context

  • The attachment upload endpoint already supports a configurable S3_UPLOAD_LIMIT environment variable
  • This would maintain consistency with the existing configuration pattern
  • Default behavior would remain unchanged (2MB) for backward compatibility
  • Affected file: apps/web/src/pages/api/upload/avatar.ts

Implementation ideas (optional)

  1. Add S3_AVATAR_UPLOAD_LIMIT to the environment variable documentation in README.md
  2. Update apps/web/src/pages/api/upload/avatar.ts to read from the environment variable with a 2MB default
  3. Optionally add validation to ensure the value is a positive integer

Would you like to work on this feature?

  • Yes, I'd like to help implement this feature
  • No, I'm just suggesting the feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions