anglemx / file-storage-bundle
支持多后端文件存储包(本地、S3、Azure)
v1.0.1
2024-04-21 17:42 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-fileinfo: *
- anglemx/php-utilities: ^1.0
- aws/aws-sdk-php: ^3.100
- microsoft/azure-storage-blob: ^1.0
- symfony/dependency-injection: ^5.4
- symfony/deprecation-contracts: ^2.1 | ^3
- symfony/event-dispatcher-contracts: ^2.4
- symfony/framework-bundle: ^5.4
- symfony/security-bundle: ^5.4
Requires (Dev)
- dms/phpunit-arraysubset-asserts: ^0.2.0
- doctrine/orm: ~2.3
- php-coveralls/php-coveralls: ^2.2
- phpunit/phpunit: ^9.0
- symfony/event-dispatcher: ^5.4
- symfony/phpunit-bridge: ^5.4
README
多后端文件存储包。支持的后端:本地、AWS S3、Azure Storage Blob。
支持类型
local
aws_s3
azure_blob_storage
在 symfony/config/packages/angle_file_storage.yaml
中创建配置文件
angle_file_storage: type: local container: file-storage username: null secret: null aws_region: null
或者将其链接到 .env
变量
angle_file_storage: type: "%env(ANGLE_FILE_STORAGE_TYPE)%" container: "%env(ANGLE_FILE_STORAGE_CONTAINER)%" username: "%env(ANGLE_FILE_STORAGE_USERNAME)%" secret: "%env(ANGLE_FILE_STORAGE_SECRET)%" aws_region: "%env(ANGLE_FILE_STORAGE_AWS_REGION)%"
然后在 .env
中添加
###> angle/file-storage-bundle ### ANGLE_FILE_STORAGE_TYPE="local" ANGLE_FILE_STORAGE_CONTAINER="container_or_path" ANGLE_FILE_STORAGE_USERNAME="myusername" ANGLE_FILE_STORAGE_SECRET="mysecret" ANGLE_FILE_STORAGE_AWS_REGION=null ###< angle/file-storage-bundle ###
本地
angle_file_storage: type: local container: path/to/files
- 如果路径是绝对路径,则按原样使用。
- 如果路径是相对路径,则将在
symfony/var/
内部创建。
Azure
angle_file_storage: type: azure_blob_storage container: azure_blob_container_name username: azure_account_name secret: azure_account_key
AWS
angle_file_storage: type: aws_s3 container: aws_s3_bucket_name username: aws_s3_access_key secret: aws_s3_secret_access_key aws_region: aws_s3_bucket_region