PHP code example of wangqs / laravel-filesystem-obs
1. Go to this page and download the library: Download wangqs/laravel-filesystem-obs 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/ */
wangqs / laravel-filesystem-obs example snippets
$app->register(Wangqs\HuaweiOBS\HWOBSServiceProvider::class);
$app->configure('hwobs');
use Wangqs\ObsV3\ObsClient;
$obsClient = ObsClient::factory ( [
'key' => $ak,
'secret' => $sk,
'endpoint' => $endpoint,
'socket_timeout' => 30,
'connect_timeout' => 10
] );
$resp = $obsClient -> listObjects(['Bucket' => $bucketName]);
foreach ( $resp ['Contents'] as $content ) {
printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
}
printf("\n");
use Wangqs\HuaweiOBS\HWobs;
$return = HWobs::all();
//or
$return = HWobs::obs()->listObjects(['Bucket' => $bucketName]);
$app->withFacades(true,[
Wangqs\HuaweiOBS\HWobs::class => 'Hwobs'
]);
// 文件系统的配置文件位于 config/filesystems.php
'hwobs' => [
'driver' => 'hwobs',
'key' => env('HWOBS_ACCESS_KEY_ID',''),
'secret' => env('HWOBS_SECRET_ACCESS_KEY',''),
'region' => env('HWOBS_DEFAULT_REGION',''),
'bucket' => env('HWOBS_BUCKET',''),
'url' => env('HWOBS_URL',''),
'endpoint' => env('HWOBS_ENDPOINT',''),
'exceptionResponseMode' => false,
],
Storage::disk('hwobs')->put('file.txt', 'Contents');
$resp = HWobs::putText("object-name","some content");
$resp = HWobs::putFile("object-name","./some.txt");
$resp = HWobs::getText("object-name");
$resp = HWobs::getStream("object-name");
$resp = HWobs::getFile("object-name",'save_path.txt');
$resp = HWobs::getMetadata("object-name");
$resp = HWobs::delete("object-name");
$resp = HWobs::all();
$resp = HWobs::deleteMulti(['object-name1','object-name2']);
sh
php artisan vendor:publish --provider="Wangqs\HuaweiOBS\HWOBSServiceProvider"