PHP code example of szwtdl / storage

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

    

szwtdl / storage example snippets



$config = [
    'access_key' => '',
    'secret_key' => '',
    'bucket' => 'szwtdl',
    'endpoint' => 'http://oss-cn-qingdao.aliyuncs.com',
    'options' => [
        'domain' => 'https://szwtdl.oss-cn-qingdao.aliyuncs.com',
        'region' => 'oss-cn-qingdao',
    ],
];

$storage = Storage::Aliyun($config);
// $storage = Storage::Qiniu($config);
// $storage = Storage::Tencent($config);

$storage->upload("./example/example.txt", "demo/example.txt");

$storage->download("demo/example.txt", "./example/123456.txt");

$storage->delete("demo/example.txt");


php artisan vendor:publish --provider="Szwtdl\Storage\ServiceProvider"

$object = "test/example.txt";
$local_path = "./example/example.txt";

##### 上传
app('storage')->upload($local_path,$object);

##### 下载
app('storage')->download($object,$$local_path);

#### 删除文件
app('storage')->delete($object);