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 );
ملحوظة
يتم دعم التحميلات غير المتزامنة باستخدام $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!