Skip to main content
This endpoint requires authentication. Users must be logged in to upload media files.

Overview

Upload media files to your personal Media Vault. Files are stored in Supabase Storage with automatic organization into folders based on the source parameter.

Request

Headers

  • Content-Type: multipart/form-data
  • Cookie: Session authentication cookie

Form Data Parameters

file
required
The media file to upload. Supported formats:
  • Images: JPEG, PNG, GIF, WebP
  • Videos: MP4, WebM
Size Limit: Maximum 100MB per file (configurable via app settings)
string
default:"general"
The source or category for organizing the uploaded file. Determines the folder structure in storage.Options:
  • general - General uploads folder
  • profile - Profile images folder
  • thumbnail - Thumbnail images folder
  • smart-caption - Smart Captions folder
  • babecock - Babecock Studio folder
  • hypnococks - HypnoCocks folder

File Upload Requirements

Allowed MIME Types

Allowed File Extensions

Security Validations

  • Path traversal characters (.., /, \\) are not allowed in filenames
  • Special characters in filenames are sanitized and replaced with underscores
  • Filenames are prefixed with timestamp and source to prevent conflicts

Storage Integration

Supabase Storage Structure

Files are organized in the user-media bucket with the following structure:
Folder Mapping:
  • source: "general" → General/
  • source: "profile" → Profile/
  • source: "thumbnail" → Thumbnails/
  • Other sources → {Source}/

Example File Path

Response

string
required
The public URL of the uploaded file in Supabase Storage
string
required
The unique filename generated for the uploaded file (includes timestamp and sanitization)
string
required
The full storage path of the file in the format: users/{userId}/{FolderName}/{fileName}
string
required
The source parameter that was provided in the request

Success Response Example

Error Responses

400 Bad Request

No file uploaded:
File too large:
Invalid file type:

500 Internal Server Error

Storage error:

503 Service Unavailable

Storage not configured:

Example Usage

cURL

JavaScript (Fetch API)

React Example with Preview

Notes

  • All uploads are tracked in user activity logs with action media_uploaded
  • The maximum upload size can be configured by admins via app settings
  • Files are automatically validated for MIME type and file extension
  • Duplicate filenames are prevented by adding timestamps
  • Uploaded files can be accessed immediately via the returned public URL