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!