dbp / relay-blob-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.173
- 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
- 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.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-doctrine-update
- dev-missing-bucket-for-delete-event
- dev-renovate/lock-file-maintenance
- dev-tests
This package is auto-updated.
Last update: 2024-09-26 13:24:50 UTC
README
DbpRelayBlobBundle
该 blob 包提供了一种抽象不同共享存储系统的 API。您可以通过 API 无授权上传文件到配置的存储桶,并获取一个短期的临时链接。认证通过签名请求进行。文件附加到存储桶,而不是所有者。
存储桶可以是应用程序或应用程序空间。例如,您可以为一个应用程序配置两个具有不同目标组的存储桶。存储桶在配置文件中配置。
要求
您需要安装 DbpRelayBlobConnector 包以使此包工作。例如 DbpRelayBlobConnectorFilesystemBundle
包安装
您可以直接从 packagist.org 安装此包。
composer require dbp/relay-blob-bundle
集成到 Relay API 服务器
- 将包添加到您的
config/bundles.php
文件中,在DbpRelayCoreBundle
之前
... Dbp\Relay\BlobBundle\DbpRelayBlobBundle::class => ['all' => true], Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true], ];
如果您将 DBP API 服务器模板 作为您的 Symfony 应用程序的模板,则这应该已经为您生成。
- 运行
composer install
以清除缓存
配置
该包具有多个配置值,您可以在应用程序中指定,无论是通过硬编码还是通过引用环境变量。
为此,在应用程序中创建 config/packages/dbp_relay_blob.yaml
,内容如下
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'
有关包配置的更多信息,请参阅 https://symfony.com.cn/doc/current/bundles/configuration.html。
开发和测试
- 安装依赖项:
composer install
- 运行测试:
composer test
- 运行 linters:
composer run lint
- 运行 cs-fixer:
composer run cs-fix
包依赖项
如果您在包中安装包,别忘了在主应用程序中拉取依赖项。
# updates and installs dependencies of dbp/relay-blob-bundle
composer update dbp/relay-blob-bundle
脚本
数据库迁移
运行此脚本以迁移数据库。在安装包后以及每次更新后运行此脚本,以使数据库适应新的源代码。
php bin/console doctrine:migrations:migrate --em=dbp_relay_blob_bundle
错误代码
请参阅 API 文档。
定时任务
清理定时任务
Blob 文件清理
:此定时任务用于清理目的。它每小时启动一次,删除旧文件。
发送报告定时任务
Blob 文件发送报告
:此定时任务将报告发送到指定的电子邮件地址或存储桶所有者。在这些报告中包含在配置中指定的时间段内将要删除的所有文件。电子邮件地址附加到这些文件或配置中有默认值。此定时任务每周一早上 9 点(UTC)启动。