Conf.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\common\services\qcloud;
  3. use app\platform\modules\system\models\SystemSetting;
  4. class Conf {
  5. // Cos php sdk version number.
  6. const VERSION = 'v4.2.2';
  7. const API_COSAPI_END_POINT = 'http://region.file.myqcloud.com/files/v2/';
  8. public static $appid;
  9. public static $secretid;
  10. public static $tsecretkey;
  11. /**
  12. * Please refer to http://console.qcloud.com/cos to fetch your app_id, secret_id and secret_key.
  13. *
  14. * @return array
  15. */
  16. public static function config()
  17. {
  18. if (config('app.framework') == 'platform') {
  19. $remote = SystemSetting::settingLoad('remote', 'system_remote');
  20. } else {
  21. global $_W;
  22. $remote = $_W['setting']['remote'];
  23. }
  24. return [
  25. 'APP_ID' => self::$appid?:$remote['cos']['appid'],
  26. 'SECRET_ID' => self::$secretid?:$remote['cos']['secretid'],
  27. 'SECRET_KEY' => self::$tsecretkey?:$remote['cos']['secretkey']
  28. ];
  29. }
  30. /**
  31. * Get the User-Agent string to send to COS server.
  32. */
  33. public static function getUserAgent() {
  34. return 'cos-php-sdk-' . self::VERSION;
  35. }
  36. }