How to change the default storage provider to S3 compatible.
Currently, all S3 compatible storage providers are supported, including AWS S3, DigitalOcean Spaces, Cloudflare R2, Supabase Storage, and others. Here’s how to switch the default storage provider to AWS S3 compatible.You can learn more about S3 service configuration in the official AWS documentation or your specific storage provider’s documentation.
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.
For detailed guidance on configuring bucket policies and permissions, refer to your storage provider’s documentation:
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 the api/signed-upload-url API route to be able to upload files to the documents bucket.
apps/api/server/api/routes/upload/index.ts
Copy
export const uploadsRouter = new Hono().basePath("/uploads").post( "/signed-upload-url", // using the authMiddleware will make sure the user is authenticated authMiddlewareWrap, validator( "query", z.object({ bucket: z.string().min(1), path: z.string().min(1), }), ), // ... async (c) => { const { bucket, path } = c.req.valid("query"); // ... const signedUrl = await getSignedUploadUrl(path, { bucket }); return c.json({ signedUrl }); throw new HTTPException(403); },);