PHP code example of jian-kuang / aliyun-oss-laravel

1. Go to this page and download the library: Download jian-kuang/aliyun-oss-laravel 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/ */

    

jian-kuang / aliyun-oss-laravel example snippets


use Illuminate\Support\Facades\Storage;
$storage = Storage::disk('oss');

Storage::disk('oss')->putFile('dir/path', '/local/path/file.txt');
Storage::disk('oss')->putFileAs('dir/path', '/local/path/file.txt', 'file.txt');

Storage::disk('oss')->put('dir/path/file.txt', file_get_contents('/local/path/file.txt'));
$fp = fopen('/local/path/file.txt','r');
Storage::disk('oss')->put('dir/path/file.txt', $fp);
fclose($fp);

Storage::disk('oss')->prepend('dir/path/file.txt', 'Prepend Text'); 
Storage::disk('oss')->append('dir/path/file.txt', 'Append Text');

Storage::disk('oss')->put('dir/path/secret.txt', 'My secret', 'private');
Storage::disk('oss')->put('dir/path/download.txt', 'Download content', ["headers" => ["Content-Disposition" => "attachment; filename=file.txt"]]);

Storage::disk('oss')->url('dir/path/file.txt');
Storage::disk('oss')->temporaryUrl('dir/path/file.txt', \Carbon\Carbon::now()->addMinutes(30));

Storage::disk('oss')->get('dir/path/file.txt'); 

Storage::disk('oss')->exists('dir/path/file.txt'); 
Storage::disk('oss')->size('dir/path/file.txt'); 
Storage::disk('oss')->lastModified('dir/path/file.txt');

Storage::disk('oss')->delete('dir/path/file.txt');
Storage::disk('oss')->delete(['dir/path/file1.txt', 'dir/path/file2.txt']);

Storage::disk('oss')->copy('dir/path/file.txt', 'dir/path/file_new.txt');
Storage::disk('oss')->move('dir/path/file.txt', 'dir/path/file_new.txt');
Storage::disk('oss')->rename('dir/path/file.txt', 'dir/path/file_new.txt');

Storage::disk('oss')->makeDirectory('dir/path'); 
Storage::disk('oss')->deleteDirectory('dir/path');

Storage::disk('oss')->files('dir/path');
Storage::disk('oss')->allFiles('dir/path');

Storage::disk('oss')->directories('dir/path'); 
Storage::disk('oss')->allDirectories('dir/path'); 

Storage::disk('oss')->appendObject('dir/path/news.txt', 'The first line paragraph.', 0);
Storage::disk('oss')->appendObject('dir/path/news.txt', 'The second line paragraph.', 25);
Storage::disk('oss')->appendObject('dir/path/news.txt', 'The last line paragraph.', 51);

$position001 = Storage::disk('oss')->appendFile('dir/path/file.zip', 'dir/path/file.zip.001', 0);
$position002 = Storage::disk('oss')->appendFile('dir/path/file.zip', 'dir/path/file.zip.002', $position001);
$position003 = Storage::disk('oss')->appendFile('dir/path/file.zip', 'dir/path/file.zip.003', $position002);