BunnyCDN.PHP.Storage
3.4.0
BunnyCDN Storage API との対話に使用される公式 PHP ライブラリ。
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!