dbp / relay-blob-bundle
A bundle for file-serving, persisting and managing
Installs: 8 664
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=8.1
- ext-json: *
- api-platform/core: ^3.2
- dbp/relay-blob-library: ^0.2.0
- dbp/relay-core-bundle: ^0.1.182
- doctrine/dbal: ^3.3 || ^4.0
- doctrine/doctrine-bundle: ^2.11
- doctrine/doctrine-migrations-bundle: ^3.3
- doctrine/migrations: ^3.5
- doctrine/orm: ^2.18 || ^3.2
- justinrainbow/json-schema: ^5.3 || ^6.0
- kekos/multipart-form-data-parser: ^1.1
- nyholm/psr7: ^1.8
- psr/log: ^1.0 || ^2 || ^3
- ramsey/uuid: ^4.7
- ramsey/uuid-doctrine: ^2.0
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/event-dispatcher-contracts: ^2.5 || ^3
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/mailer: ^6.4
- symfony/mime: ^6.4
- symfony/psr-http-message-bridge: ^6.4
- symfony/serializer: ^6.4
- symfony/uid: ^6.4
- twig/twig: ^3.8
Requires (Dev)
- ext-curl: *
- friendsofphp/php-cs-fixer: ^3.50
- phpstan/phpstan: ^1.10.59
- phpstan/phpstan-phpunit: ^1.3.16
- phpstan/phpstan-symfony: ^1.3.7
- phpunit/phpunit: ^10.1
- symfony/browser-kit: ^6.4
- symfony/error-handler: ^6.4
- symfony/http-client: ^6.4
- symfony/monolog-bridge: ^6.4
- symfony/monolog-bundle: ^3.10
- symfony/phpunit-bridge: ^7.0.4
- vimeo/psalm: ^5.22.2
- dev-main
- v0.1.66
- v0.1.65
- v0.1.64
- v0.1.63
- v0.1.62
- v0.1.61
- v0.1.60
- v0.1.59
- v0.1.58
- v0.1.57
- v0.1.56
- v0.1.55
- v0.1.54
- v0.1.53
- v0.1.52
- v0.1.51
- v0.1.50
- v0.1.49
- v0.1.48
- v0.1.47
- v0.1.46
- v0.1.45
- v0.1.44
- v0.1.43
- v0.1.42
- v0.1.41
- v0.1.40
- v0.1.39
- v0.1.38
- v0.1.37
- v0.1.36
- v0.1.35
- v0.1.34
- v0.1.33
- v0.1.32
- v0.1.31
- v0.1.30
- v0.1.29
- v0.1.28
- v0.1.27
- v0.1.26
- v0.1.25
- v0.1.24
- v0.1.23
- v0.1.22
- v0.1.21
- v0.1.20
- v0.1.19
- v0.1.18
- v0.1.17
- v0.1.16
- v0.1.15
- v0.1.14
- v0.1.13
- v0.1.12
- v0.1.11
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-renovate/all-minor-patch
- dev-next789
- dev-next42
- dev-renovate/lock-file-maintenance
- dev-tests
This package is auto-updated.
Last update: 2024-11-18 07:06:53 UTC
README
DbpRelayBlobBundle
GitHub | Packagist | Changelog
The blob bundle provides an API for abstracting different shared storage systems. You can upload a file unauthorized via the API to a configured bucket and gets a short ephemeral link. Authentication takes place via signed requests. The file is attached to the bucket, not to an owner.
A bucket can be an application or an application space. For example, you can have two buckets with a different target group for one application. A bucket is configured in the config file.
Requirements
You need a DbpRelayBlobConnector bundle installed to make this bundle working. E.g. DbpRelayBlobConnectorFilesystemBundle
Bundle installation
You can install the bundle directly from packagist.org.
composer require dbp/relay-blob-bundle
Integration into the Relay API Server
- Add the bundle to your
config/bundles.php
in front ofDbpRelayCoreBundle
:
... Dbp\Relay\BlobBundle\DbpRelayBlobBundle::class => ['all' => true], Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true], ];
If you were using the DBP API Server Template as template for your Symfony application, then this should have already been generated for you.
- Run
composer install
to clear caches
Configuration
The bundle has multiple configuration values that you can specify in your app, either by hard-coding it, or by referencing an environment variable.
For this create config/packages/dbp_relay_blob.yaml
in the app with the following
content:
dbp_relay_blob: database_url: %env(resolve:DATABASE_URL)%' reporting_interval: "0 11 * * MON" # when notification cronjob should run cleanup_interval: "*/5 * * * *" # when cleanup cronjob should run file_integrity_checks: true # if file integrity checks should be performed periodically integrity_check_interval: "0 0 1 * *" # when integrity check cronjob should run bucket_size_check_interval: "0 2 * * 1" # when bucket size check cronjob should run quota_warning_interval: "0 7 * * *" # when bucket quota should be checked and if needed warning emails should be sent additional_auth: true # enable client credential flow buckets: test_bucket: service: 'Dbp\Relay\BlobConnectorFilesystemBundle\Service\FilesystemService' # The path to a dbp relay blob connector service internal_bucket_id: '019072b9-7736-7430-aabd-ad1bbeeebacf' # A given internal id for a bucket bucket_id: 'test-bucket' # friendly name of the bucket thats also used for the request key: '12345' # public key for signed request quota: 500 # Max quota in MB notify_when_quota_over: 70 # percent of quota when the bucket owner should be notified that the storage is running out report_when_expiry_in: 'P30D' # duration of how much in advance a bucket owner or user should be warned about the deletion of files bucket_owner: 'john@example.com' # Email who will be notified when quota is reached link_expire_time: 'P7D' # Max expire time of sharelinks in ISO 8601 warn_quota: # Notification configuration how emails are sent when the quota is about to be reached dsn: '%env(TUGRAZ_MAILER_TRANSPORT_DSN)%' from: 'noreply@tugraz.at' to: 'john@example.com' subject: 'Blob Bucket Quota Warning' html_template: 'emails/warn-quota.html.twig' reporting: # Reporting configuration how emails are sent when files are about to expire dsn: '%env(TUGRAZ_MAILER_TRANSPORT_DSN)%' from: 'noreply@tugraz.at' to: 'john@example.com' # this email is a fallback, if no email field of a file is set subject: 'Blob file Deletion Report' html_template: 'emails/reporting.html.twig' integrity: # Integrity check configuration how emails are sent when file hash or metadata hash do not match with the saved file or metadata dsn: '%env(TUGRAZ_MAILER_TRANSPORT_DSN)%' from: 'noreply@tugraz.at' to: 'john@example.com' subject: 'Blob File Integrity Check Report' html_template: 'emails/integrity.html.twig' additional_types: - generic_id_card: '%kernel.project_dir%/config/packages/schemas/relay-blob-bundle/test-bucket/generic_id_card.json'
For more info on bundle configuration see https://symfony.com/doc/current/bundles/configuration.html.
Development & Testing
- Install dependencies:
composer install
- Run tests:
composer test
- Run linters:
composer run lint
- Run cs-fixer:
composer run cs-fix
Bundle dependencies
Don't forget you need to pull down your dependencies in your main application if you are installing packages in a bundle.
# updates and installs dependencies of dbp/relay-blob-bundle
composer update dbp/relay-blob-bundle
Scripts
Database migration
Run this script to migrate the database. Run this script after installation of the bundle and after every update to adapt the database to the new source code.
php bin/console doctrine:migrations:migrate --em=dbp_relay_blob_bundle
Error codes
See the API documentation.
CronJobs
Cleanup Cronjob
This cronjob is for cleanup purposes. It starts every hour and deletes old files.
Send Report Cronjob
This cronjob sends reports to given email addresses, or the bucket owner. In these reports there are all files which are going to be deleted in the timeframe specified in the config. The email address are attached to these files or there is a default in the config. This cronjob starts every Monday at 9 o'clock in the Morning (UTC).
Quota Warning
This cronjob sends reports to the in warn_quota
configured email.
This email lets the configured person know before the bucket space is used up.
An email gets sent after the bucket is filled to a certain percentage, configured with the option notify_when_quota_over
.
The option quota_warning_interval
indicates in which interval this should get checked.
Bucket Size Check
This cronjob sends reports to the in bucket_size
configured email.
This email lets the configured person know if a bucket is inconsistent, either because the number of entries in the table is different than in the storage backend or because the sum of filesizes stored in the database is different than the sum of filesize of the actually stored files.
An email is sent if some inconsistencies are detected.
The option bucket_size_check_interval
indicates in which interval this should get checked.
Integrity Check
This cronjobs sends reports to the in integrity
configured email.
This emails lets the configured person know if the metadata or file integrity checks fail. This means, that the metadata or file hashes, which are stored upon upload, are different then the hashes of the metadata or file that are currently stored. This could indicate bitrot or manual changes in the database or file.
An email is sent if some inconsistencies are detected.
The option integrity_check_interval
indicates in which interval this should get checked.
The option file_integrity_checks
can be used to enable or disable the integrity checks.