bootstrap.php 893 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require dirname(__DIR__) . '/vendor/autoload.php';
  3. define('USER_NAME', 'tester');
  4. define('PWD', 'grjxv2mxELR3');
  5. define('BUCKET', 'sdkimg');
  6. define('PIC_PATH', dirname(__FILE__) . '/assets/sample.jpeg');
  7. define('PIC_SIZE', filesize(PIC_PATH));
  8. function getFileUrl($path)
  9. {
  10. return "http://" . BUCKET . ".b0.upaiyun.com/" . ltrim($path, '/');
  11. }
  12. function getUpyunFileSize($path)
  13. {
  14. $url = getFileUrl($path);
  15. $ch = curl_init($url);
  16. curl_setopt($ch, CURLOPT_NOBODY, true);
  17. curl_setopt($ch, CURLOPT_HEADER, true);
  18. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  19. $return = curl_exec($ch);
  20. preg_match('~^HTTP/1.1 (\d{3})~', $return, $match1);
  21. preg_match('~Content-Length: (\d+)~', $return, $match2);
  22. if (isset($match1[1]) && $match1[1] == 200) {
  23. return isset($match2[1]) ? intval($match2[1]) : false;
  24. } else {
  25. return false;
  26. }
  27. }