Files
orico-official-website/config/filesystem.php
2025-07-25 16:29:18 +08:00

99 lines
4.2 KiB
PHP

<?php
return [
// 默认磁盘
'default' => 'local',
// 磁盘列表
'disks' => [
'local' => [
'type' => 'local',
'root' => app()->getRuntimePath() . 'storage',
],
'public' => [
// 磁盘类型
'type' => 'local',
// 磁盘路径
'root' => app()->getRootPath() . 'public/storage',
// 磁盘路径对应的外部URL路径
'url' => '/storage',
// 可见性
'visibility' => 'public',
],
'image' => [
// 磁盘类型
'type' => 'local',
// 磁盘路径
'root' => app()->getRootPath() . 'public/storage/images',
// 磁盘路径对应的外部URL路径
'url' => '/storage/images',
// 可见性
'visibility' => 'public',
],
'video' => [
// 磁盘类型
'type' => 'local',
// 磁盘路径
'root' => app()->getRootPath() . 'public/storage/videos',
// 磁盘路径对应的外部URL路径
'url' => '/storage/videos',
// 可见性
'visibility' => 'public',
],
'public_qiniu' => [
// 磁盘类型
'type' => \filesystem\driver\Qiniu::class,
// bucker 名称
'bucket' => 'orico-official-website',
// 访问密钥
'access_key' => 'dOsTum4a5qvhPTBbZRPX0pIOU7PZWRX7htKjztms',
// 密钥
'secret_key' => 'KFxsGbnErkALFfeGdMa8QWTdodJbamMX0iznLe-q',
// 外部URL
'base_url' => '//szw73dlk3.hn-bkt.clouddn.com',
// 路径
'path_prefix' => '/storage',
// 文件名称回调,可为文件名添加特定标志,以便可以在后续识别
'filename_generator' => function (\think\file\UploadedFile $file, callable $context_generator = null): callable {
return function() use ($file, $context_generator) {
// 为文件名称添加配置名,以为后续可能根据文件名识别文件所属存储配置信息
$marker = '_' . base64_encode('public_qiniu');
$filename = $context_generator ? $context_generator($file) : null;
if ($filename == null) {
return date('Ymd') . '/' . md5(microtime(true) . $file->getPathname()) . $marker;
}
return $filename . $marker;
};
},
],
'video_qiniu' => [
// 磁盘类型
'type' => \filesystem\driver\Qiniu::class,
// bucker 名称
'bucket' => 'orico-official-website',
// 访问密钥
'access_key' => 'dOsTum4a5qvhPTBbZRPX0pIOU7PZWRX7htKjztms',
// 密钥
'secret_key' => 'KFxsGbnErkALFfeGdMa8QWTdodJbamMX0iznLe-q',
// 外部URL
'base_url' => '//szw73dlk3.hn-bkt.clouddn.com',
// 路径
'path_prefix' => '/storage/videos',
// 文件名称回调,可为文件名添加特定标志,以便可以在后续识别
'filename_generator' => function (\think\file\UploadedFile $file, callable $context_generator = null): callable {
return function() use ($file, $context_generator) {
// 为文件名称添加配置名,以为后续可能根据文件名识别文件所属存储配置信息
$marker = '_' . base64_encode('video_qiniu');
$filename = $context_generator ? $context_generator() : null;
if ($filename == null) {
return date('Ymd') . '/' . md5(microtime(true) . $file->getPathname()) . $marker;
}
return $filename . $marker;
};
},
]
// 更多的磁盘配置信息
],
];