PHP code example of toosmart / file-store-sdk

1. Go to this page and download the library: Download toosmart/file-store-sdk 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/ */

    

toosmart / file-store-sdk example snippets


use TooSmart\FileStoreSdk\Client;

$client = new Client('https://your-filestore-api.url', 'your-api-key');

$client->login();

$client->setBucket('your-bucket-name');

$response = $client->getFile('path/in/bucket/filename.pdf');
$fileContents = $response['body']; // If not JSON, this is the raw file data

$contentList = [
    ['type' => 'file', 'value' => '/local/path/to/file.pdf'],
];

$response = $client->uploadContentList('folder/filename.pdf', $contentList, 'application/pdf', true);
$linkToFile = $response['body']['url'] ?? null;

$contentList = [
    ['type' => 'html', 'value' => '<h1>Hello, World!</h1>'],
];

$response = $client->uploadContentList('folder/hello.html', $contentList, 'text/html', true);