unisharp/s3-presigned 问题修复 & 功能扩展

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

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

unisharp/s3-presigned

Composer 安装命令:

composer require unisharp/s3-presigned

包简介

An AWS S3 package for pre-signed upload purpose in Laravel and PHP.

README 文档

README

php-badge packagist-badge

Approach

Traditionally to upload a file from users to a private S3 bucket needs two internet connections. One is from client to your own server, and the other is from your server to S3 bucket. Using pre-signed upload can solve this problem. Your server issues pre-signed upload url for client to upload in advance, and the client can upload his file to S3 bucket directly within an authorized time period. This package wraps S3 pre-signed api for PHP and Laravel.

Installation

composer require unisharp/s3-presigned

Laravel 5

Setup

Add ServiceProvider and Facade in app/config/app.php.

Unisharp\S3\Presigned\S3PresignedServiceProvider::class,
'S3Presigned' => Unisharp\S3\Presigned\Facades\S3Presigned::class,

It supports package discovery for Laravel 5.5.

Configuration

Add settings to .env file.

// required
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET=

// optional
AWS_REGION=ap-northeast-1
AWS_VERSION=latest
AWS_S3_PREFIX=

APIs

/*
 * @return string
 */
public function getSimpleUploadUrl($key, $minutes = 10, array $options = [], $guzzle = false)
  • $key: your s3 file key, a prefix will be prepended automatically.
  • $minutes: expire time for the pre-signed url.
  • $options: see AWS docs to find more.
  • $guzzle: set true if you want to get a guzzle instance instead of string.
/*
 * @return array('endpoint', 'inputs')
 */
public function getUploadForm($minutes = 10, array $policies = [], array $defaults = [])
  • $minutes: expire time for the pre-signed url.
  • $policies: see AWS docs to find more.
  • $defaults: default key-values you want to add to form inputs.

for more detail, please see: AWS docs

/*
 * @return array
 */
public function listObjects($directory = '', $recursive = false)
/*
 * @return boolean
 */
public function deleteObject($key)
/*
 * @return string
 */
public function getBaseUri()
/*
 * @return this
 */
public function setPrefix($prefix)
/*
 * @return string
 */
public function getPrefix()
/*
 * @return this
 */
public function setBucket($bucket)
/*
 * @return string
 */
public function getBucket()
/*
 * @return Aws\S3\S3Client
 */
public function getClient()

统计信息

  • 总下载量: 1.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 10
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固