ctala/yii2-aws-s3 问题修复 & 功能扩展

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

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

ctala/yii2-aws-s3

最新稳定版本:V0.6

Composer 安装命令:

composer require ctala/yii2-aws-s3

包简介

Contenedor de las clases de S3 para Yii2

README 文档

README

An Amazon S3Client wrapper as Yii2 component.

Yii2 AWS S3 can only work with one bucket per a component configuration.

The component currently supports CloudFront (getting a CDN url for an object in a S3 bucket).

Installation

  1. Run the Composer command to install the latest stable version:

    composer require ctala/yii2-aws-s3
    
  2. Add component to config/main.php

    'components' => [
        // ...
        's3bucket' => [
            'class' => \CTala\Storage::className(),
            'region' => 'your region',
            'credentials' => [ // Aws\Credentials\CredentialsInterface|array|callable
                'key' => 'your aws s3 key',
                'secret' => 'your aws s3 secret',
            ],
            'bucket' => 'your aws s3 bucket',
            'cdnHostname' => 'http://example.cloudfront.net',
            'defaultAcl' => \CTala\Storage::ACL_PUBLIC_READ,
            'debug' => true, // bool|array
        ],
        // ...
    ],

Usage

Uploading objects

// creating an object
$data = ['one', 'two', 'three'];
Yii::$app->get('s3bucket')->put('path/to/s3object.ext', Json::encode($data));

// uploading an object by streaming the contents of a stream
$resource = fopen('/path/to/local/file.ext', 'r+');
Yii::$app->get('s3bucket')->put('path/to/s3object.ext', $resource);

Uploading files

Yii::$app->get('s3bucket')->upload('path/to/s3object.ext', '/path/to/local/file.ext');

Uploading large files using multipart uploads with custom options

$concurrency = 5;
$minPartSize = 536870912; // 512 MB

Yii::$app->get('s3bucket')->multipartUpload(
    'path/to/s3object.ext',
    '/path/to/local/file.ext',
    $concurrency,
    $minPartSize
);

Reading objects

/** @var \Aws\Result $result */
$result = Yii::$app->get('s3bucket')->get('path/to/s3object.ext');
$data = $result['Body'];

Saving objects to a file

Yii::$app->get('s3bucket')->get('path/to/s3object.ext', '/path/to/local/file.ext');

Deleting objects

Yii::$app->get('s3bucket')->delete('path/to/s3object.ext');

Getting a plain URL

$url = Yii::$app->get('s3bucket')->getUrl('path/to/s3object.ext');

Creating a pre-signed URL

$url = Yii::$app->get('s3bucket')->getPresignedUrl('path/to/s3object.ext', '+10 minutes');

Getting a CDN URL

$url = Yii::$app->get('s3bucket')->getCdnUrl('path/to/s3object.ext');

Listing objects

$result = Yii::$app->get('s3bucket')->getList('path/');
foreach ($result['Contents'] as $object) {
    echo $object['Key'] . PHP_EOL;
}

##ChangeLog

  • 0.6 : Added Create Folder, Added Iterator for All files.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 60
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-26