Provides a CephClient for storing files UNY cloud object storage
composer require mrcoco/ceph-uny dev-masterinclude 'vendor/autoload.php';
use CephUny\Client;
$config = array(
'version' => 'latest',
'region' => '',
'endpoint' => 'AWS_HOST',
'credentials' => array(
'key' => 'AWS_KEY',
'secret' => 'AWS_SECRET_KEY',
)
);
$client = new Client($config);
$bucketName = 'my-bucket';$client->createBucket($bucketName);foreach ($client->getBuckets() as $bucket) {
var_dump($bucket);
}$file = "uny.png";
try{
$client->putFromFile($bucketName,$file);
}catch (Aws\S3\Exception\S3Exception $e){
echo "There was an error uploading the file.\n";
}$file = "uny.png";
try{
$result = $client->putFromFile($bucketName,$file);
echo $result['ObjectURL'].PHP_EOL;
}catch (Aws\S3\Exception\S3Exception $e){
echo "There was an error uploading the file.\n";
}$fileName = basename($file);
$result = $client->getFile($bucketName, $fileName);
var_dump($result);$bucketName = "mybocket";
$file = "uny.png";
$fileName = basename($file);
$expired = "+30 minutes";
$url = $client->preSignUrl($bucketName, $fileName,$expired);
echo $url;