1. Go to this page and download the library: Download limen/fileflake 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/ */
limen / fileflake example snippets
use Limen\Fileflake\Config;
$config = [
Config::KEY_FILE_META_CONNECTION => 'mongodb', // g::KEY_NODE_META_CONNECTION => 'mongodb', // ly
Config::KEY_LOAD_BALANCE_STRICT => true, // optional, default value is false
// 'collection' => 'FileStorage1', // storage node collection
],
[
'id' => 2,
'connection' => 'mongodb',
'collection' => 'FileStorage2',
],
],
Config::KEY_LOCALIZE_DIR => '/tmp/fileflake/localize', // leflake\Storage\FileMetaStorage::class,
],
];
$filePath = '/path/to/file';
$file = new \Limen\Fileflake\Protocols\InputFile($filePath, 'fileflake.png', filesize($filePath), 'png', 'image/png');
$fileflake = new \Limen\Fileflake\Fileflake($config);
/** @var string $fileId md5 */
$fileId = $fileflake->put($file);
/** @var \Limen\Fileflake\Protocols\OutputFile only file meta data */
$fileMeta = $fileflake->getMeta($fileId);
/** @var \Limen\Fileflake\Protocols\OutputFile */
$localFile = $fileflake->get($fileId);
$localFile->localize(); // make a local copy
/** @var string $localPath path of local copy */
$localPath = $localFile->path;
while ($chunk = $localFile->nextChunk()) { // iterate file chunks without making a local copy
// do something
}
// remove file
$fileflake->remove($fileId);
$fileflake->get($fileId); // return null
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.