feat: add support for S3 as a storage provider (#659)

* add s3

* instance the s3 client dynamically

* refactor code

* fix format

* add docs

* add docs

* fix issue with s3 upload if you use the base path,
fix issue with archiving -> disable archiving for s3

* split file service in local and s3 file service and fix s3 upload chunking

* add working download/view

* add new features to local service (from main branch)

* revert s3 service and add working delete/remove functionality

* refactor s3 service

* Update backend/src/file/s3.service.ts

Co-authored-by: Elias Schneider <login@eliasschneider.com>

* Update frontend/src/components/admin/configuration/ConfigurationNavBar.tsx

Co-authored-by: Elias Schneider <login@eliasschneider.com>

* Update docs/docs/setup/s3.md

Co-authored-by: Elias Schneider <login@eliasschneider.com>

* Update backend/prisma/seed/config.seed.ts

Co-authored-by: Elias Schneider <login@eliasschneider.com>

* add note for ZIP archive in docs

* create logger instance

* make s3 instance dynamic

* add icon import

* remove console.logs

* add correct pdf viewing format

* add storage provider to share

* refactor: run formatter

* chore: add prisma migration

* fix: don't expose `storageProvider`

* chore: improve config variables description

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
Mattia Müggler
2024-12-19 12:06:49 +01:00
committed by GitHub
parent 0b406f0464
commit 5a54fe4cb7
16 changed files with 2222 additions and 139 deletions

32
docs/docs/setup/s3.md Normal file
View File

@@ -0,0 +1,32 @@
---
id: s3
---
# S3
You are able to add your preferred S3 provider, like AWS, DigitalOcean, Exoscale or Infomaniak. However, if you don't
want to store your files on a S3 bucket, you don't have to. Consider that this feature is `DISABLED` per default.
## Configuration
You can configure your S3 provider and bucket by going to the configuration page in your admin dashboard `/admin/config/s3`.
| Key | Description | Value |
|:-----------|:-------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------|
| enabled | This property enables the storage location on your configured S3 bucket. | `true` |
| endpoint | This property is the host from your S3 bucket. | `sos-ch-dk-2` |
| region | This property is the region where the bucket is located. | `sos-ch-dk-2.exo.io` |
| bucketName | This property is the name of your S3 bucket. | `my-bucket` |
| bucketPath | This property defines the folder where you want to store your files which are uploaded. Hint: Don't put a slash in the start or end. | `my/custom/path` (or leave it empty for root) |
| key | This is the access key you need to access to your bucket. | `key-asdf` |
| secret | This is the secret you need to access to your bucket. | `secret-asdf` |
Don't forget to save the configuration. :)
## ClamAV
Consider that ClamAV scans are not available at the moment if you store your files in a S3 bucket.
## ZIP
Creating ZIP archives is not currently supported if you store your files in an S3 bucket.