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
Response
Success (200):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
- Validates glasses authentication
- Parses metadata from request body
- Validates file is an image
- Saves photo to disk in
uploads/photosdirectory - Broadcasts to apps subscribed to
PHOTO_TAKENevents - Returns public URL for the photo
File Validation
- Only accepts files with
image/*mimetype - Maximum file size: 10MB
- Requires valid
requestIdin 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 toPHOTO_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
| Code | Description |
|---|---|
| 400 | Invalid request (missing file, invalid metadata, wrong mimetype) |
| 401 | Unauthorized - invalid glasses token |
| 404 | User session not found |
| 500 | Internal server error |
Notes
- Photos are saved to the file system in
uploads/photosdirectory - 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_URLenvironment variable - Apps receive photo data through WebSocket broadcast, not via REST
- The endpoint handles multipart form data uploads