This commit is contained in:
make
2025-04-21 17:47:12 +08:00
parent 24cef96a26
commit 7ef217c1b9
523 changed files with 0 additions and 93250 deletions

View File

@@ -1,98 +0,0 @@
<?php
namespace storage;
use League\Flysystem\Filesystem;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use Aws\S3\S3Client;
use League\Flysystem\Adapter\Local;
class StorageCore
{
private static $instance = null;
/**
* Undocumented variable
*
* @var Filesystem
*/
private $Filesystem;
/**
* Undocumented variable
*
* @var Local
*/
private $Adapter;
private function __construct()
{
$arrConfig = config('storage');
$this->Adapter = new Local(
$arrConfig['local']['dir']
);
$this->Filesystem = new Filesystem($this->Adapter);
}
/**
* Undocumented function
*
* @return self
*/
public static function getInstance(): self
{
if (self::$instance == null) {
self::$instance = new self();
}
return self::$instance;
}
public function set($strKey, $strContent)
{
$strContent = zstd_compress($strContent);
return $this->Filesystem->write($strKey, $strContent);
}
public function writeStream(string $strPath, $Resource)
{
$this->Filesystem->writeStream($strPath, $Resource);
}
public function put($strKey, $strContent, array $arrConfig = [])
{
$strContent = zstd_compress($strContent);
return $this->Filesystem->put($strKey, $strContent, $arrConfig);
}
public function write($strKey, $strContent, array $arrConfig = [])
{
$strContent = zstd_compress($strContent);
return $this->Filesystem->write($strKey, $strContent, $arrConfig);
}
public function update($strKey, $strContent, array $arrConfig = [])
{
$strContent = zstd_compress($strContent);
return $this->Filesystem->update($strKey, $strContent, $arrConfig);
}
public function read($strKey)
{
try {
$Stream = $this->Filesystem->readStream($strKey);
$strContent = stream_get_contents($Stream);
$strContent = zstd_uncompress($strContent);
return $strContent;
} catch (\Exception $e) {
return '';
}
}
public function has($strKey)
{
return $this->Filesystem->has($strKey);
}
}