BunnyCDN.PHP.Storage
3.4.0
ไลบรารี PHP อย่างเป็นทางการที่ใช้สำหรับการโต้ตอบกับ BunnyCDN Storage API
composer require bunnycdn/storage
สร้างอินสแตนซ์ของ BunnyStorageClient
พร้อมรายละเอียดการรับรองความถูกต้อง
$ client = new Bunny Storage Client ( ' access-key ' , ' storage-zone ' , Bunny Storage Region :: SINGAPORE );
ตัวสร้าง BunnyCDNStorage ใช้พารามิเตอร์ต่อไปนี้:
$ client -> upload ( ' /path/to/local/file.txt ' , ' remote/path/hello-world.txt ' );
เช็คซัมสามารถปิดการใช้งานได้โดยใช้พารามิเตอร์ $withChecksum
:
$ client -> upload ( ' /path/to/local/file.txt ' , ' remote/path/hello-world.txt ' , false );
บันทึก
การอัปโหลดแบบ Async ได้รับการสนับสนุนด้วย $client->uploadAsync()
มันจะส่งคืน GuzzleHttpPromisePromiseInterface
$ client -> download ( ' remote/path/hello-world.txt ' , ' /path/to/local/file.txt ' );
$ items = $ client -> listFiles ( ' remote/path/ ' );
ส่งกลับอาร์เรย์ของวัตถุ FileInfo
$ item = $ client -> info ( ' remote/path/hello-world.txt ' );
ส่งกลับอินสแตนซ์ของ FileInfo
$ client -> delete ( ' remote/path/hello-world.txt ' );
$ errors = $ client -> deleteMultiple ([ ' file1.txt ' , ' file2.txt ' , ' non-existing.txt ' ]);
var_dump ( $ errors );
/*
array(1) {
'non-existing.txt' =>
string(16) "Object not found"
}
*/
$ content = ' Hello, world! ' ;
$ client -> putContents ( ' hello-world.txt ' , $ content );
เช็คซัมสามารถปิดการใช้งานได้โดยใช้พารามิเตอร์ $withChecksum
:
$ content = ' Hello, world! ' ;
$ client -> putContents ( ' hello-world.txt ' , $ content , false );
$ content = $ client -> getContents ( ' hello-world.txt ' );
echo $ content ; // Hello, world!