Search by

anton-am / selectel-cloud-api

Anton-Am

A simple API wrapper for Selectel object storage

Package info

github.com/Anton-Am/selectel-cloud-api

pkg:composer/anton-am/selectel-cloud-api

Statistics

Installs: 456

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.7 2026-11-20 10:42 UTC

This package is auto-updated.

Last update: 2026-11-20 10:45:54 UTC


README

A simple API wrapper for Selectel object storage.

Installation

  • Using Composer:
composer require anton-am/selectel-cloud-api

Connecting

require_once('vendor/autoload.php');

use AntonAm\Selectel\Cloud\Manager;

$key = 'ACCOUNT_ID_USER';
$secret = 'USER_PASSWORD';
$containerName = 'CONTAINER_NAME';

$client = new Manager($key, $secret, $containerName);

All available options:

Manager(REQUIRED KEY, REQUIRED SECRET, OPTIONAL CONTAINER NAME, OPTIONAL REGION, OPTIONAL HOST, OPTIONAL CLIENT OPTIONS);

 

Timeouts and retries

By default the client uses short timeouts and a single retry, so that an unavailable storage endpoint fails fast instead of hanging for minutes:

Option Default
http.connect_timeout 3 s
http.timeout 10 s
retries 1

Any extra AWS SDK client options can be passed as the last constructor argument (or via setClient()). They are merged recursively over the defaults, so only the values you need have to be overridden.

$client = new Manager($key, $secret, $containerName, 'ru-1', 'https://s3.storage.selcloud.ru', [
    'http' => [
        'connect_timeout' => 5,
        'timeout'         => 30,
    ],
    'retries' => 2,
]);

 

Uploading/Downloading Files

$pathToFileInContainer = 'image.png';
$pathToFile = '/app/image.png';
$client->file($pathToFileInContainer)->setFileData($pathToFile)->create();


$downloadFile = 'image.png';
$saveAs = '/app/folder/downloaded-image.png';

$client->file($downloadFile)->download($saveAs);

 

Deleting Files/Folders

$pathToFileInContainer = 'image.png';

// fast, default: DeleteObject is idempotent, so no extra requests are made
$client->file($pathToFileInContainer)->delete();

delete() accepts an optional $wait flag. When enabled, the client polls the storage with HeadObject until the object (bucket) is really gone. It is disabled by default because deletion is applied synchronously and every extra poll costs time and requests.

// wait until the object is really gone (up to 5 HEAD requests, 1 second apart)
$client->file('image.png')->delete(true);

// the flag is passed down to every file of the directory
$client->directory('photos')->delete(true);

$client->bucket()->delete(true);