PHP code example of php-sword / storage

1. Go to this page and download the library: Download php-sword/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/ */

    

php-sword / storage example snippets


Storage::getInstance($config);

$config = [

    //资源储存方式 local|alioss|api
    'drive' => 'api',

    //资源api服务器接口配置 -若res_type=local生效
    'dev_local' => [
        // 资源目录路径 以/结尾
        'public' => EASYSWOOLE_ROOT. '/Public/'
    ],

    //资源api服务器接口配置 -若res_type=api生效
    // 接口服务端代码:https://github.com/php-sword/storage/blob/main/tests/api.php
    'dev_api' => [
        'Host' => 'ac.youhost.cn',
        'Port' => 80,
        'Gateway' => '/api.php',
        'User' => 'xoshe',
        'Secret' => '***',
        'OutTime' => -1
    ],

    // 阿里oss配置 -若res_type=alioss生效
    'dev_alioss' => [
        'AccessKey'   => 'LTA***sZh',
        'Secret'      => 'NSc38*****fn7z5',
        'Endpoint'    => "http://oss-cn-chengdu.aliyuncs.com",
        'Bucket'      => '***'
    ],
];

$storage = Storage::getInstance()->getObject();
$storage->upload(...);