bootstrap.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. // @codingStandardsIgnoreFile
  3. require_once __DIR__ . '/../autoload.php';
  4. use Qiniu\Auth;
  5. $accessKey = getenv('QINIU_ACCESS_KEY');
  6. $secretKey = getenv('QINIU_SECRET_KEY');
  7. $testAuth = new Auth($accessKey, $secretKey);
  8. $bucketName = getenv('QINIU_TEST_BUCKET');
  9. $key = 'php-logo.png';
  10. $key2 = 'niu.jpg';
  11. $testStartDate = '2020-08-18';
  12. $testEndDate = '2020-08-19';
  13. $testGranularity = 'day';
  14. $testLogDate = date('Y-m-d',strtotime("-1 days"));
  15. $bucketNameBC = 'phpsdk-bc';
  16. $bucketNameNA = 'phpsdk-na';
  17. $bucketNameFS = 'phpsdk-fs';
  18. $bucketNameAS = 'phpsdk-as';
  19. $dummyAccessKey = 'abcdefghklmnopq';
  20. $dummySecretKey = '1234567890';
  21. $dummyAuth = new Auth($dummyAccessKey, $dummySecretKey);
  22. //cdn
  23. $timestampAntiLeechEncryptKey = getenv('QINIU_TIMESTAMP_ENCRPTKEY');
  24. $customDomain = "http://sdk.peterpy.cn";
  25. $customDomain2 = "sdk.peterpy.cn";
  26. $customCallbackURL = "https://qiniu.timhbw.com/notify/callback";
  27. $tid = getenv('TRAVIS_JOB_NUMBER');
  28. if (!empty($tid)) {
  29. $pid = getmypid();
  30. $tid = strstr($tid, '.');
  31. $tid .= '.' . $pid;
  32. }
  33. function qiniuTempFile($size, $randomized = true)
  34. {
  35. $fileName = tempnam(sys_get_temp_dir(), 'qiniu_');
  36. $file = fopen($fileName, 'wb');
  37. if ($randomized) {
  38. $rest_size = $size;
  39. while ($rest_size > 0) {
  40. $length = min($rest_size, 4 * 1024);
  41. if (fwrite($file, random_bytes($length)) == false) {
  42. return false;
  43. }
  44. $rest_size -= $length;
  45. }
  46. } else if ($size > 0) {
  47. fseek($file, $size - 1);
  48. fwrite($file, ' ');
  49. }
  50. fclose($file);
  51. return $fileName;
  52. }