Skip to content

feat(backend): implement file upload readiness flow and garbage colle…#307

Closed
muhsar27 wants to merge 1 commit into
codebestia:mainfrom
muhsar27:feat-file-upload-flow
Closed

feat(backend): implement file upload readiness flow and garbage colle…#307
muhsar27 wants to merge 1 commit into
codebestia:mainfrom
muhsar27:feat-file-upload-flow

Conversation

@muhsar27

Copy link
Copy Markdown

Description

Closes #227
This PR implements a robust upload readiness flow to ensure files are fully uploaded to S3 before they can be shared in conversations, and cleans up any abandoned uploads.

Key Changes:

Database Tracking: Added a new files table (and fileStatusEnum) to track uploaded files and their states (pending vs. ready).
Uploads Router:
POST /uploads: Initializes an upload by inserting a pending record and returning an S3 presigned PUT URL.
POST /uploads/:fileId/complete: Confirms the upload by querying S3 to verify the file's presence and matching size, updating the status to ready upon success.
Messaging Validation: Updated the send_message and edit_message WebSocket handlers to enforce file readiness. Any message attempting to reference a file that isn't ready is immediately rejected.
Garbage Collection: Implemented a background service (garbageCollection.ts) that runs hourly to automatically delete any pending unconfirmed files older than 24 hours from both the database and S3.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Other

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally
  • My code follows the project's coding standards

@codebestia

Copy link
Copy Markdown
Owner

@muhsar27
Please fix the conflicts and the CI

@muhsar27 muhsar27 closed this Jun 29, 2026
@muhsar27 muhsar27 deleted the feat-file-upload-flow branch June 29, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POST /uploads/:fileId/complete — confirm + verify

2 participants