Skip to main content

Upload Photo

Upload a photo from smart glasses to the cloud.

Endpoint

Headers

This endpoint requires glasses authentication, not regular user authentication.

Request Body

Multipart form data with:
  • file: The image file (JPEG, PNG, etc.)
  • metadata: JSON string containing request metadata
Metadata format:

Response

Success (200):
Error (400):
Error (404):
Error (500):

Implementation

  • File: packages/cloud/src/routes/photos.routes.ts:109-198
  • Middleware: validateGlassesAuth - Validates glasses JWT token
  • File Limits: 10MB maximum file size
  • Storage: Memory storage with file system persistence

Upload Process

  1. Validates glasses authentication
  2. Parses metadata from request body
  3. Validates file is an image
  4. Saves photo to disk in uploads/photos directory
  5. Broadcasts to apps subscribed to PHOTO_TAKEN events
  6. Returns public URL for the photo

File Validation

  • Only accepts files with image/* mimetype
  • Maximum file size: 10MB
  • Requires valid requestId in metadata
  • File must have a buffer

Automatic Cleanup

Photos older than 5 minutes are automatically deleted from the upload directory when new photos are uploaded.

Broadcast Event

Apps subscribed to PHOTO_TAKEN stream receive the photo data via WebSocket:
  • Photo buffer data
  • MIME type

Test Endpoint

Simple test endpoint to verify photo routes are working.

Endpoint

Response

Error Codes

Notes

  • Photos are saved to the file system in uploads/photos directory
  • Files are named with timestamp and UUID for uniqueness
  • Old photos are automatically cleaned up after 5 minutes
  • The photo URL is constructed using CLOUD_PUBLIC_URL environment variable
  • Apps receive photo data through WebSocket broadcast, not via REST
  • The endpoint handles multipart form data uploads
The current implementation has a hardcoded user email (“loriamistadi75@gmail.com”) at line 148 which should be replaced with proper user identification from the request.