S3 Uploads
The backend never receives image file data directly. Instead, it generates a short-lived signed URL that the frontend uses to upload directly to S3.
Upload Flow
Section titled “Upload Flow”-
Frontend requests a signed URL — calls
POST /api/v1/sign-s3with the filename and file type. -
Backend generates the URL — uses AWS SDK with the credentials from
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION, andS3_BUCKETenv vars. Signed URL expires in 5 minutes. -
Backend responds with:
{"signedRequest": "https://s3.amazonaws.com/bucket/file.jpg?X-Amz-Signature=...","url": "https://s3.amazonaws.com/bucket/file.jpg"} -
Frontend uploads directly to S3 — sends a
PUTrequest tosignedRequestwith the file as the body. No data goes through the Express server. -
Frontend saves
url— stores the public S3 URL in the article’s image/thumbnail field.
Endpoint
Section titled “Endpoint”POST /api/v1/sign-s3Request body:
{ "fileName": "my-image.jpg", "fileType": "image/jpeg"}