dbp/relay-blob-connector-filesystem-bundle

用于将 blob 数据存储在文件系统中的 relay-blob-bundle 连接器包

v0.1.21 2024-09-11 09:12 UTC

README

GitHub | Packagist | 变更日志

此包是 relay-blob-bundle 的连接器包,用于在文件系统中存储 blob 数据。它实现了 blob 包的 DatasystemProviderServiceInterface。它可以保存文件到特定路径,重命名这些文件,删除这些文件,或者返回短暂的共享链接。

要求

您需要安装 DbpRelayBlob 包才能使用此包,请参阅 DbpRelayBlobBundle

包安装

您可以直接从 packagist.org 安装此包。

composer require dbp/relay-blob-connector-filesystem-bundle

集成到 Relay API 服务器

  • 将此包添加到您的 config/bundles.php 中,在 DbpRelayCoreBundle 前面
...
Dbp\Relay\BlobBundle\DbpRelayBlobConnectorFilesystemBundle::class => ['all' => true],
Dbp\Relay\BlobBundle\DbpRelayBlobBundle::class => ['all' => true],
Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true],
];

如果您将 DBP API 服务器模板 作为您的 Symfony 应用的模板,那么这应该已经为您生成了。

  • 运行 composer install 清除缓存

配置

该包有多个配置值,您可以在您的应用程序中指定,无论是通过硬编码还是通过引用环境变量。

为此,在应用程序中创建 config/packages/dbp_relay_blob_connector_filesystem.yaml,内容如下

dbp_relay_blob_connector_filesystem:
  path: '%kernel.project_dir%/var/blobFiles' # path where files should be placed
  link_url: 'https://:8000/' # base link_url of the api

有关包配置的更多信息,请参阅 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 and dbp/relay-blob-connector-filesystem-bundle
composer update dbp/relay-blob-bundle
composer update dbp/relay-blob-connector-filesystem-bundle

脚本

数据库迁移

运行此脚本以迁移数据库。在安装包后以及每次更新后运行此脚本,以使数据库适应新的源代码。

php bin/console doctrine:migrations:migrate --em=dbp_relay_blob_connector_filesystem_bundle

功能

/blob/filesystem/{identifier}

GET

如果共享链接有效且存在,则返回共享链接 ID 的二进制文件响应

错误代码

计划任务

清理计划任务

Blob Connector Filesystem Database cleanup:此计划任务是用于清理目的。它删除所有无效的共享链接,并每小时启动一次。