feat(backend): implement file upload readiness flow and garbage colle…#307
Closed
muhsar27 wants to merge 1 commit into
Closed
feat(backend): implement file upload readiness flow and garbage colle…#307muhsar27 wants to merge 1 commit into
muhsar27 wants to merge 1 commit into
Conversation
Owner
|
@muhsar27 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Checklist