Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.
/ glow-api Public archive

A set of functions for working with Glow CDN

License

Notifications You must be signed in to change notification settings

bavix/glow-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Glow CDN

A set of functions for working with Glow CDN:

  • Bucket creation;
  • Creating views;
  • Authorization;
  • File access;
  • Uploaded files;

How to start

$client = new \Bavix\GlowApi\HttpClient(BASE_URL, APP_TOKEN);
$api = new \Bavix\GlowApi\Api($client);
$api->createBucket('users');
$api->createView('users', [
    'name' => 'avatar',
    'type' => 'contain',
    'width' => 160,
    'height' => 160,
    'quality' => 75,
    'optimize' => true,
    'webp' => true,
]);

$files = (new \Bavix\GlowApi\File\Upload())
    ->addFile('id_1.svg', 'https://stat.babichev.net/svg/logo.svg')
    ->addFile('id_1.png', 'https://stat.babichev.net/png/logo.png')
;

$response = $api->writeFile('users', $files); // upload to cdn

// Glow CDN will automatically generate views and you can get them from the links:
//
// SVG:
// original: http://glow.local/capsule/users/id_1.svg
// thumbnail: http://glow.local/capsule/users:avatar/id_1.svg.jpg
// thumbnail+webp: http://glow.local/capsule/users:avatar/id_1.svg.jpg.webp
//
// PNG:
// original: http://glow.local/capsule/users/id_1.png
// thumbnail: http://glow.local/capsule/users:avatar/id_1.png
// thumbnail+webp: http://glow.local/capsule/users:avatar/id_1.png.webp

Supported by

Supported by JetBrains