feat: 七牛云默认上传到智能分层

This commit is contained in:
augushong
2025-08-31 11:51:29 +08:00
parent b21dab1695
commit 6248c554c6
2 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace think\filesystem\adapter;
use League\Flysystem\Config;
use League\Flysystem\UnableToWriteFile;
use Overtrue\Flysystem\Qiniu\QiniuAdapter as QiniuQiniuAdapter;
class QiniuAdapter extends QiniuQiniuAdapter
{
public function write(string $path, string $contents, Config $config): void
{
$mime = $config->get('mime', 'application/octet-stream');
/**
* @var Error|null $error
*/
[, $error] = $this->getUploadManager()->put(
$this->getAuthManager()->uploadToken($this->bucket, null, 3600 , [
'fileType'=>5
]),
$path,
$contents,
null,
$mime,
$path
);
if ($error) {
throw UnableToWriteFile::atLocation($path, $error->message());
}
}
}

View File

@@ -3,10 +3,10 @@
namespace think\filesystem\driver;
use League\Flysystem\FilesystemAdapter;
use think\filesystem\adapter\QiniuAdapter;
use think\filesystem\Driver;
use Overtrue\Flysystem\Qiniu\QiniuAdapter;
class Qiniu extends Driver
class Qiniu extends Driver
{
protected function createAdapter(): FilesystemAdapter
{