PHP code example of eposgit / yii2-hejiang-storage

1. Go to this page and download the library: Download eposgit/yii2-hejiang-storage 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/ */

    

eposgit / yii2-hejiang-storage example snippets


    'components' => [
        'class' => 'Hejiang\Storage\Components\StorageComponent',
        'basePath' => 'temp/',
        'driver' => [
            'class' => 'Hejiang\Storage\Drivers\Local',
            'accessKey' => '',
            'secretKey' => '',
            'bucket' => '',
        ]
    ]
    

    $storage = \Yii::$app->storage;
    

    $storage->setDriver('Hejiang\Storage\Drivers\Local', []);
    

    $file = $storage->getUploadedFile('FILE-FIELD-NAME');
    

    $url = $file->saveAs('NEW-FILE-NAME.EXT');
    // or
    $url = $file->saveWithOriginalExtension('NEW-FILE-BASE-NAME');
    // or
    $url = $file->saveAsUniqueHash();