reconnect/s3bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

reconnect/s3bundle

Composer 安装命令:

composer require reconnect/s3bundle

包简介

Symfony S3 Bundle

README 文档

README

S3Bundle helps you connect you Symfony application to a S3 bucket, or any bucket that implements S3 API. It is a wrapper around the great league/flysystem-aws-s3-v3 library

Installation

composer require reconnect/s3bundle

If you are not using Symfony flex, you will need a few extra steps to enable and configure the bundle

Usage

You need to update the following environment variables to make this bundle works

BUCKET_HOST=http://localhost:9000/ // For a local bucket for example
BUCKET_NAME=files
BUCKET_KEY=files_access
BUCKET_SECRET=files_secret

Then, you can inject the FlysystemS3Client.php to do some common operations on buckets, such as :

Fetching a document presigned URL

use Reconnect\S3Bundle\Service\FlysystemS3Client;
// ...
private FlysystemS3Client $S3Client;

public function __construct(FlysystemS3Client $s3Adapter)
{
    $this->documentService = $S3Client;
}
// ...
// The  $objectKey is the key we used to identify the file in the bucket
$presignedUrl = $S3Client->getPresignedUrl($objectKey);

Posting a document

use Reconnect\S3Bundle\Service\FlysystemS3Client;
// ...
private FlysystemS3Client $S3Client;

public function __construct(FlysystemS3Client $s3Adapter)
{
    $this->documentService = $S3Client;
}
// ...
// Get a file as an instance of File
// This method returns the key of the uploaded file in the bucket
// This $key is a random UuidV4
$key = $S3Client->uploadFile($file);

Generating a thumbnail

You can also generate a thumbnail, it handles images and pdfs

use Reconnect\S3Bundle\Service\FlysystemS3Client;
// ...
private FlysystemS3Client $S3Client;

public function __construct(FlysystemS3Client $s3Adapter)
{
    $this->documentService = $S3Client;
}
// ...
// Get a file as an instance of UploadedFile
// This method returns the key of the uploaded thumbnail file in the bucket
// This $key is a random UuidV4
$thumbnailKey = $S3Client->generateThumbnail($file);

Configuration reference

# Default configuration for extension with alias: "reconnect_s3"
reconnect_s3:
    bucketHost: ~ # Required
    bucketName: ~ # Required
    bucketKey: ~ # Required
    bucketSecret: ~ # Required

if you use .env file, you can import values from the env file

reconnect_s3:
    bucketHost: '%env(BUCKET_HOST)%'
    bucketName: '%env(BUCKET_NAME)%'
    bucketKey: '%env(BUCKET_KEY)%'
    bucketSecret: '%env(BUCKET_SECRET)%'

and define them in the .env file

BUCKET_HOST=https://localhost:9000/
BUCKET_NAME=bucket
BUCKET_KEY=bucket_key
BUCKET_SECRET=bucket_secret

统计信息

  • 总下载量: 4.16k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固