Uploads
In this part of the documentation, we are going to show you how to integrate S3 bucket for managing file uploads.
Last updated
In this part of the documentation, we are going to show you how to integrate S3 bucket for managing file uploads.
Last updated
We've used the Cloudflare R2 bucket in this boilerplate. You can use any S3 bucket you want. Follow the instructions below to integrate an S3 bucket into your SaaS boilerplate.
Login to your Cloudflare account.
Go to R2->Create Bucket fill in the bucket name and save.
Also, update this env variable with your Bucket name.
R2_BUCKET_NAME=YOUR_BUCKET_NAME
Generate the Secret and Access Key: Copy the Account ID and save it to the env file, after that, click on the Manage R2 API Tokens button.
R2_ACCOUNT_ID
It'll redirect you to this page. Now click on the Create API token button.
Now assign the Token name, then select Object Read & Write permission and choose the Bucket you created earlier. Once you are done, scroll down and click the Create API Token button.
Once you click on that button you'll see the Access Key ID and the Secret Access Key. Go ahead and copy them and update the env file.
This is it. We've used the R2 bucket to store the user profile image. You can use the upload action and modify it for other resources like downloadable files etc.
Now we have to configure the CORS policy to enable the file upload from your App.
Go to your Bucket->Settings
Scroll down and click on the Edit CORS Policy
Update the CORS policy with the following code and save it.