mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
34 lines
838 B
PHP
34 lines
838 B
PHP
<?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());
|
|
}
|
|
}
|
|
}
|