Storage.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @desc StorageService
  4. *
  5. * @author Tinywan(ShaoBo Wan)
  6. * @date 2022/3/7 20:03
  7. */
  8. declare(strict_types=1);
  9. namespace support;
  10. /**
  11. * @see Storage
  12. * @mixin Storage
  13. *
  14. * @method static array uploadFile(array $config = []) 上传文件
  15. * @method static array uploadBase64(string $base64, string $extension = 'png') 上传Base64文件
  16. * @method static array uploadServerFile(string $file_path) 上传服务端文件
  17. */
  18. class Storage extends \Tinywan\Storage\Storage
  19. {
  20. /**
  21. * @desc 存储磁盘
  22. * @param string|null $name
  23. * @param bool $_is_file_upload
  24. * @return mixed
  25. * @author Tinywan(ShaoBo Wan)
  26. */
  27. public static function disk(string $name = null, bool $_is_file_upload = true, array $arguments = [])
  28. {
  29. $storage = $name ?? self::getDefaultStorage();
  30. $config = self::getConfig($storage);
  31. return new $config['adapter'](array_merge(
  32. $config, ['_is_file_upload' => $_is_file_upload], $arguments[0]
  33. ));
  34. }
  35. /**
  36. * @param $name
  37. * @param $arguments
  38. * @return mixed
  39. * @author Tinywan(ShaoBo Wan)
  40. */
  41. public static function __callStatic($name, $arguments)
  42. {
  43. return static::disk(null, true, $arguments)->{$name}(...$arguments);
  44. }
  45. }