Files
Choose between Cloudfalre R2, AWS S3, or Google Cloud Storage
Configuration
This choice can be made using the GoFast CLI or by modifying the docker-compose.yml
file.
via CLI
Possible options are Cloudflare R2
, AWS S3
, Google Cloud Storage
and Local (folder)
.
via Docker Compose
Possible options are r2
, s3
, gcs
and local
.
Files Configuration
Depending on the provider, you need to set the following environment variables in the docker-compose.yml
file:
- for
r2
, setR2_ENDPOINT
,R2_ACCESS_KEY
, andR2_SECRET_KEY
. - for
s3
, setS3_REGION
,S3_ACCESS_KEY
, andS3_SECRET_KEY
. - for
gcs
, setGOOGLE_APPLICATION_CREDENTIALS
. - for
local
, setFILE_DIR
.
Implementations Details
Regardless of the protocol configuration, File operations (uploads and downloads) will always be handled using HTTP requests. This approach is much simpler to implement compared to using gRPC, which would require splitting files into chunks.
The files have a seperate file for HTTP routes: /http/route_file.go
.
The local provider stores files in a local folder, while the other providers store files in their respective cloud storage services.
Adding a New Provider
To add a new provider, follow these steps in the /file/provider.go
file:
- Add the new provider to the
Provider
constant.
- Create a new provider struct.
- Return the new provider in the
NewProvider
function:
- Implement the required methods:
-
Add any new secrets in the
env.go
file. -
Fill in the
docker-compose.yml
file with the new provider configuration.
Getting Secrets
Cloudflare R2
- Go to Cloudflare R2 and create an account.
- Create a new bucket
- On
R2
dashboard, click onManage R2 API Tokens
and create a new token. - Set the
R2_ENDPOINT
,R2_ACCESS_KEY
, andR2_SECRET_KEY
in thedocker-compose.yml
file.
AWS S3
- Go to the AWS Console and create an account.
- Go to the S3 dashboard.
- Create a new bucket.
- Go to the IAM dashboard.
- Create a new user with
AmazonS3FullAccess
policy. - Set the
S3_REGION
,S3_ACCESS_KEY
, andS3_SECRET_KEY
in thedocker-compose.yml
file.
Google Cloud Storage
- Go to the Google Cloud Console and create an account.
- Create a new project.
- Go to the Storage dashboard.
- Create a new bucket.
- Go to the IAM & Admin dashboard.
- Create a new service account with
Storage Admin
role. - Download the JSON key and set the
GOOGLE_APPLICATION_CREDENTIALS
in thedocker-compose.yml
file.
Need help?
Visit our discord server to ask any questions, make suggestions and give feedback :).
Was this page helpful?