File.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Module\File;
  3. use Illuminate\Support\Facades\Storage;
  4. class File
  5. {
  6. public static function getPath($name,$disk=null)
  7. {
  8. $src = Storage::disk($disk)->get($name);
  9. return $src;
  10. }
  11. /**
  12. * 获取 真实储存地址
  13. *
  14. * @param $path
  15. * @return string
  16. */
  17. static public function getVisibility($path)
  18. {
  19. $disk = config('admin.upload.disk');
  20. if (config("filesystems.disks.{$disk}")) {
  21. $src = Storage::disk($disk)->getVisibility($path);
  22. }
  23. return $src;
  24. }
  25. /**
  26. * 获取
  27. * @param $path
  28. * @return string
  29. */
  30. static public function prefixPath($path)
  31. {
  32. $disk = config('admin.upload.disk');
  33. if (config("filesystems.disks.{$disk}")) {
  34. /**
  35. * @var \Illuminate\Filesystem\FilesystemAdapter $storage
  36. */
  37. $src= Storage::disk($disk)->path($path);
  38. }
  39. return $src;
  40. }
  41. static public function fileExists($path)
  42. {
  43. $disk = config('admin.upload.disk');
  44. if (config("filesystems.disks.{$disk}")) {
  45. /**
  46. * @var \Illuminate\Filesystem\FilesystemAdapter $storage
  47. */
  48. $src= Storage::disk($disk)->fileExists($path);
  49. }
  50. return $src;
  51. }
  52. }