PHP code example of 4slovo / s3client

1. Go to this page and download the library: Download 4slovo/s3client 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/ */

    

4slovo / s3client example snippets


use Aws\S3\Exception\NoSuchKeyException;
use Chslovo\S3\S3FsClient;

y1';
$secretKey = 'verySecretKey1';

$s3client = new S3FsClient($endpoint, $accessKey, $secretKey);

/* Загрузка файла */
$hash = $s3client->upload('test.php', 'test.php');

var_export(["hash" => $hash]);

/* Получение содержимого файла */
$fileContent = $s3client->download($hash);

var_export(["fileContent" => $fileContent]);

/* Удаление файла */
$s3client->delete($hash);

try {
    $fileContent = $s3client->download($hash);
    var_export(["fileContent" => $fileContent]);
} catch ( NoSuchKeyException $exception){
    echo "файл не существует";
}