PHP code example of meisam-mulla / sfs-client

1. Go to this page and download the library: Download meisam-mulla/sfs-client 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/ */

    

meisam-mulla / sfs-client example snippets


use MeisamMulla\SfsClient\StretchFS;

$client = new StretchFS([
    'username' => 'your_username', // optional if you have a token
    'password' => 'your_password', // optional if you have a token
    'domain' => 'sfsserver.net', // SFS server
    'port' => 8161, // Default port
    'token' => 'your_token', // If you already have a token
]);

$token = $client->generateToken();

$client->destroyToken(token: 'iu23gn43g2i4i');

$client->folderCreate(folderPath: '/test');

$client->folderDelete(folderPath: '/test');

$client->fileList(folderPath: '/');

$client->fileUpload(filePath: '/home/user/somefile.txt', folderPath: '/');

$client->fileUploadFromString(filePath: '/text.txt', contents: 'contents of text.txt');

$contents = $client->fileDownload(filePath: '/text.txt');

$stream = $client->fileDownloadStream(filePath: '/text.txt');

$contents = $client->fileDetail(filePath: '/text.txt');

$client->fileDelete(filePath: '/text.txt');

$response = $client->fileDownloadUrl(filePath: '/text.txt', seconds: 3600);

$job = $client->jobCreate(description: [
    "callback" => [
        'request' => [
            'method' => 'GET',
            'url' => "http://some.url/job.complete",
        ],
    ],
    "resource" => [
        [
            "name" => 'somefile.zip',
            "request" => [
                "method" => "GET",
                "url" => "https://url.to/file.zip",
            ]
        ]
    ]
], priority: 12, category: 'ingest');

$client->jobUpdate(handle: '5sE4674U4ft2', changes: [
    "resource" => [
        [
            "name" => 'somefile.zip',
            "request" => [
                "method" => "GET",
                "url" => "https://url.to/file.zip",
            ]
        ]
    ]
]);

$client->jobStart(handle: 'FQukh4sIMN4F');

$client->jobDetail(handle: 'FQukh4sIMN4F');

$client->jobAbort(handle: 'FQukh4sIMN4F');

$client->jobRetry(handle: 'FQukh4sIMN4F');

$client->jobRemove(handle: 'FQukh4sIMN4F');

$client->jobContentExists(handle: 'FQukh4sIMN4F', file: 'file.zip');