1. Go to this page and download the library: Download linkorb/filespace 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/ */
linkorb / filespace example snippets
use Aws\S3\S3Client;
use FileSpace\Service\PdoService;
use ObjectStorage\Adapter\S3Adapter;
// Instantiate an S3 connection
$s3client = S3Client::factory(array(
'key' => 'my_s3_key',
'secret' => 'my_s3_secret'
));
// Get a storage adapter based on the s3 client
$storage = new S3Adapter($s3client, 'my-bucket-name', 'my/key/prefix/');
// Get a PDO connection
$pdo = ... // TODO;
// Instantiate the File Space Service:
$service = new PdoFileSpaceService($pdo, $storage);
// test if a 'space' has been created:
$space_key = 'account-x.contact.c001';
if (!$service->hasSpace($space_key)) {
$service->createSpace($space_key, "Customer 1: John Johnson");
}
$space = $service->getSpace($space_key);
// List all files in the space
$files = $service->getFiles($space);
foreach ($files as $file) {
echo $file->getKey() . ': ' . $file->getSizeOriginalDisplay() . "\n";
}
// Upload a file into this space
$service->upload($space, 'contract-final.pdf', '/home/john/Downloads/contract.pdf');
// Download a file from this space:
$service->download($space, 'invoice-1234.pdf', '/home/john/invoices/invoice-1234.pdf');
// Delete a file from the space:
$service->deleteFile($space, 'remove-me.txt');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.