This commit is contained in:
Default
2025-03-18 22:51:45 +08:00
parent eb9035a7ae
commit 526d3f47f4
103 changed files with 542 additions and 4025 deletions

View File

@@ -0,0 +1,84 @@
<?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 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)
{
$Stream = $this->Filesystem->readStream($strKey);
$strContent = stream_get_contents($Stream);
$strContent = zstd_uncompress($strContent);
return $strContent;
}
public function has($strKey)
{
return $this->Filesystem->has($strKey);
}
}