Presigned Upload Flow for Dashboard API - #136
Merged
yash-pouranik merged 5 commits intoApr 26, 2026
Merged
Conversation
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.
Presigned Upload Flow for Dashboard API
Issue: #131
Description
Implements a three-step presigned URL upload architecture for the dashboard API, enabling large file uploads directly to S3/R2 without proxying bytes through Node.js. This mirrors the implementation in PR #129 for the public API but uses dashboard-appropriate auth (JWT/session via
loadProjectForAdminmiddleware).Changes
Files Modified
apps/dashboard-api/src/routes/projects.jsPOST /:projectId/storage/upload-request- Generate presigned URL with quota validationPOST /:projectId/storage/upload-confirm- Verify upload completion and charge quota atomicallyauthMiddleware → verifyEmail → loadProjectForAdminapps/dashboard-api/src/controllers/project.controller.jsNew handlers:
requestUpload()- Validates size, peeks at quota (no charge yet), returns signed URL and tokenconfirmUpload()- Verifies file exists, compares size, atomically charges quota, cleans up on failureNew helpers:
parsePositiveSize()- Validates positive finite numbers for file sizenormalizeProjectPath()- Prevents path traversal; validates projectId prefixbestEffortDeleteUploadedObject()- Non-fatal cleanup helper for failed confirmationsdocs-legacy/storage.mdFiles Created
apps/dashboard-api/src/__tests__/storage.presigned.controller.test.jsrequestUploadandconfirmUploadhandlersapps/dashboard-api/src/__tests__/routes.projects.storage.test.jsKey Features
Quota Management
requestUpload: Peeks at quota without chargingconfirmUpload: Charges quota atomically only after file verificationSecurity
..segments)Reliability
Shared Infrastructure
@urbackend/commonhelpers:getPresignedUploadUrl,verifyUploadedFilegetStorageandgetBucketfunctionsTest Results
Summary by CodeRabbit
New Features
Documentation
Tests
Chores