mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 11:02:48 +08:00
feat: 七牛云默认上传到智能分层
This commit is contained in:
33
extend/think/filesystem/adapter/QiniuAdapter.php
Normal file
33
extend/think/filesystem/adapter/QiniuAdapter.php
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,10 @@
|
|||||||
namespace think\filesystem\driver;
|
namespace think\filesystem\driver;
|
||||||
|
|
||||||
use League\Flysystem\FilesystemAdapter;
|
use League\Flysystem\FilesystemAdapter;
|
||||||
|
use think\filesystem\adapter\QiniuAdapter;
|
||||||
use think\filesystem\Driver;
|
use think\filesystem\Driver;
|
||||||
use Overtrue\Flysystem\Qiniu\QiniuAdapter;
|
|
||||||
|
|
||||||
class Qiniu extends Driver
|
class Qiniu extends Driver
|
||||||
{
|
{
|
||||||
protected function createAdapter(): FilesystemAdapter
|
protected function createAdapter(): FilesystemAdapter
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user