PHP code example of farhan928 / yii2-aws-s3-client

1. Go to this page and download the library: Download farhan928/yii2-aws-s3-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

farhan928 / yii2-aws-s3-client example snippets


// add this in your component section
's3Client' => [           
        'class' => 'farhan928\AwsS3\S3Client',
        'key' => 'YOUR_AWS_KEY',
        'secret' => 'YOUR_AWS_SECRET',            
        'bucket' => 'YOUR_BUKCET',            
],

Yii::$app->s3Client->url('file.png');

Yii::$app->s3Client->temporaryUrl('file.png', 5); //second argument is the duration in minute

Yii::$app->s3Client->put('file.png', file_get_contents('https://i.imgur.com/hAjCMan.jpg'))

Yii::$app->s3Client->copy('old.png', 'file/new.png')

Yii::$app->s3Client->move('old.png', 'file/new.png')

// get all files
Yii::$app->s3Client->files('path/to/your/folder/');

// get certain type of files
Yii::$app->s3Client->files('path/to/your/folder/', ['jpg', 'png']);