BunnyCDN.PHP.Storage
3.4.0
Die offizielle PHP-Bibliothek, die für die Interaktion mit der BunnyCDN-Speicher-API verwendet wird.
composer require bunnycdn/storage
Erstellen Sie eine Instanz von BunnyStorageClient
mit den Authentifizierungsdetails
$ client = new Bunny Storage Client ( ' access-key ' , ' storage-zone ' , Bunny Storage Region :: SINGAPORE );
Der BunnyCDNStorage-Konstruktor akzeptiert die folgenden Parameter:
$ client -> upload ( ' /path/to/local/file.txt ' , ' remote/path/hello-world.txt ' );
Die Prüfsumme kann mit dem Parameter $withChecksum
deaktiviert werden:
$ client -> upload ( ' /path/to/local/file.txt ' , ' remote/path/hello-world.txt ' , false );
Notiz
Asynchrone Uploads werden mit $client->uploadAsync()
unterstützt. Es wird ein GuzzleHttpPromisePromiseInterface
zurückgegeben.
$ client -> download ( ' remote/path/hello-world.txt ' , ' /path/to/local/file.txt ' );
$ items = $ client -> listFiles ( ' remote/path/ ' );
Gibt ein Array von FileInfo-Objekten zurück.
$ item = $ client -> info ( ' remote/path/hello-world.txt ' );
Gibt eine Instanz von FileInfo zurück.
$ 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 );
Die Prüfsumme kann mit dem Parameter $withChecksum
deaktiviert werden:
$ content = ' Hello, world! ' ;
$ client -> putContents ( ' hello-world.txt ' , $ content , false );
$ content = $ client -> getContents ( ' hello-world.txt ' );
echo $ content ; // Hello, world!