Files
Choose between Cloudfalre R2, AWS S3, Google Cloud Storage, or Azure Blob Storage
Implementation
The main logic can be found in the service-go-user/domain/file/provider.go
file.
The local provider stores files in a local folder, while the other providers store files in their respective cloud storage services.
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
, Azure Blob Storage
and Local (folder)
.
via Docker Compose
Possible options are r2
, s3
, gcs
, azblobl
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
azblob
, setAZBLOB_ACCOUNT_NAME
andAZBLOB_ACCOUNT_KEY
. - for
local
, setFILE_DIR
.
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.
Azure Blob Storage
- Go to the Azure Portal and create an account.
- Create a new storage account.
- Go to the storage account and create a new container.
- Go to the
Access keys
section and copy theConnection string
. - Set the
AZBLOB_ACCOUNT_NAME
andAZBLOB_ACCOUNT_KEY
in thedocker-compose.yml
file.
Need help?
Visit our discord server to ask any questions, make suggestions and give feedback :).
Was this page helpful?