PHP code example of chipk4 / selectel

1. Go to this page and download the library: Download chipk4/selectel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chipk4 / selectel example snippets



SelectelApi::storageInfo();

//You may use virtual folders like 'newFolder/newFileName.jpg'
SelectelApi::storeFile('container', 'filePath/1243.jpg', 'newFileName.jpg')

SelectelApi::containerInfo('your_container')

SelectelApi::storageContainerList()

/*
* You can use private or public container type
* Public container present by default
* For private container use 
*/
SelectelApi::getFile('container', 'fileName', true);
//For public container
SelectelApi::getFile('container', 'fileName');

SelectelApi::containerFileList('container_name');

//If you want to do something else, you can get an instance of the underlying API:
SelectelApi::getApi();

// config/app.php
'providers' => [
    ...
    Chipk4\Selectel\SelectelApiServiceProvider::class,
    ...
];

// config/app.php
'aliases' => [
    ..
    'SelectelApi' => Chipk4\Selectel\SelectelApiFacade::class,
];

return [
    /*
     * This is agreement number from system
     */
    'authUser' => env('SELECTEL_LOGIN'),

    /*
     * Password for cloud storage service.
     * Note: it's different with account password
     */
    'authKey' => env('SELECTEL_PASSWORD'),

    /*
     * API url
     */
    'apiUrl' => 'https://auth.selcdn.ru/',

    /*
     * Default value for request timeout
     */
    'timeout' => 10,

    /*
     * Default storage url
     */
    'storageUrl' => env('SELECTEL_STORAGE_URL', ''),

    /*
     * Response view
     * Can be in json or xml
     */
    'returnView' => env('SELECTEL_RETURN_VIEW', 'json'),
    
];

  use SelectelApi;
  
  SelectelApi::getFile('container', 'fileName');

    use Chipk4\Selectel\CloudStorage;
    
    public function test(CloudStorage $storage) 
    {
        $storage->getFile('container', 'fileName');
    }
bash
php artisan vendor:publish --provider="Chipk4\Selectel\SelectelApiServiceProvider"