Feat/98 file upload api#222
Conversation
add migration schema for the uploads table to store files. add table to DBTables constant.
add uploadFile method to save file data. update the api to save the data and leverage validation functions.
Deploying volunteer with
|
| Latest commit: |
ea9a9f6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7ecb8ff5.volunteer-ekr.pages.dev |
| Branch Preview URL: | https://feat-98-file-upload-api.volunteer-ekr.pages.dev |
add a public api to fetch public files from r2. add a private api to fetch protected files from r2. add a data function to fetch file info from uploads table.
Co-authored-by: Marco Campos <me@madcampos.dev>
Co-authored-by: Marco Campos <me@madcampos.dev>
move file access level check after validating file extension
reverse the logic in accessLevelCheck for files.
delete orphaned file from r2 if file data not stored in database.
remove unwanted comments from files/index.ts
remove unwanted comments from files/validation.ts
rename the file schema migration from user-uploads to create-uploads. add a filename field to keep the filename separate from id. remove the accessLevel field, enabling only public types.
update avatar url in the profile table instead of creating a separate uploads table. delete uploads table.
clean up file validation methods based on public and private access.
update the POST files/upload api to upload avatar in Profile table. update the GET files/ api to allow public file access from R2 bucket using file prefix.
| defaultHook: statusResponseFormatter | ||
| }); | ||
|
|
||
| // NOTE: Add more specific GET routes before the following route only |
There was a problem hiding this comment.
Love to see this new cool feature.
Some comments.
A public service for a resource which cost money? That sounds like a bad idea for whomevers credit card goes into the Cloudflare account. The service needs to be scoped
to retreving Avatars ONLY and with authentication.
There was a problem hiding this comment.
We're building a image uplaod service specificaly not a file upload service. I think the naming should reflect that and has mentioned above scoped for that specifially.
There was a problem hiding this comment.
As per our conversation, we need to code a check to ensure we don't go voer the "free" tier limit. There's no way to to have alarms or limits setup at the admin console level. Checking everything we utilize(resource) is not optimal but we can find a more optimal way after the MVP is in production.
There was a problem hiding this comment.
+1 on the limiter. If we are using a tier-limited service, we would need to manually setup a logger that tracks this and send an alert once it reaches a certain threshold.
|
Status Update: On hold due to infrastructure decision delegation for Cloudflare R2. |
Summary
Add file upload api for uploading files to R2 buckets.
Tests
WIP - Pending
Additional information
Closes #98