Permissions
Before you start managing files, make sure you have configured storage. Most S3-compatible storage providers allow you to configure bucket permissions and access policies. It’s crucial to properly set these up to secure your files and control who can access them. Here are some key security recommendations:- Keep your bucket private by default
- Use IAM roles and policies to manage access
- Enable server-side encryption for sensitive data
- Configure CORS settings appropriately for client-side uploads
- Regularly audit bucket permissions and access logs
- Making your bucket public is strongly discouraged as it can expose sensitive data and lead to unauthorized access and unexpected costs from bandwidth usage.
- AWS S3 Security Documentation
- DigitalOcean Spaces Security
- Cloudflare R2 Security
- Supabase Storage Security
1. Update the environment variables
Next, add these environment variables to your.env.local
file:
apps/app/.env
2. Update the existing storage files
Update theindex.ts
and client.ts
to use the new uploadthing
packages:
packages/storage/index.ts
3. Prepare upload endpoint
As explained on the overview page, ShipThing uses the presigned URLs to upload files to your storage provider. So what we need to do first is to implement theapi/signed-upload-url
API route to be able to upload files to the documents
bucket.
apps/api/server/api/routes/upload/index.ts
4. Upload files from the UI
Then, you can use it to upload files to the generated presigned URL from your frontend code:upload.tsx