Yun.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Upload\Lib;
  3. use Dever;
  4. class Yun
  5. {
  6. public function get($id)
  7. {
  8. $upload = Dever::db('upload/upload')->one($id);
  9. if (!$upload) {
  10. return false;
  11. }
  12. if ($upload['save_type'] == 1) {
  13. return false;
  14. }
  15. if (!$upload['yun']) {
  16. return false;
  17. }
  18. $config = Dever::db('upload/yun')->one($upload['yun']);
  19. if (!$config) {
  20. return false;
  21. }
  22. }
  23. public function view($file)
  24. {
  25. $data = parse_url($file);
  26. $path = ltrim($data['path'], '/');
  27. $temp = explode('/', $path);
  28. $config = $this->get($temp[0]);
  29. if (!$config) {
  30. return $file;
  31. }
  32. return Dever::load('upload/lib/yun')->getMethod($config['type'])->view($config, $file);
  33. }
  34. public function getMethod($type)
  35. {
  36. if ($type == 1) {
  37. $method = 'oss';
  38. } else {
  39. $method = 'qiniu';
  40. }
  41. return Dever::load('upload/lib/view/' . $method);
  42. }
  43. }