Skip to content

PHP SDK undefined method Qiniu\Config::getRsHostV2() #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jeanli-mai opened this issue Jan 12, 2023 · 2 comments
Closed

PHP SDK undefined method Qiniu\Config::getRsHostV2() #400

jeanli-mai opened this issue Jan 12, 2023 · 2 comments

Comments

@jeanli-mai
Copy link

问题描述

  • 代码
function actionTest($fileName) {
    $auth = new Auth(QINIU_ACCESS_KEY, QINIU_SECRET_KEY);
    $bucketMgr = new BucketManager($auth);
    return $bucketMgr->stat($this->bucket, $fileName);
}
  • 报错
Error: Call to undefined method Qiniu\Config::getRsHostV2() in /workspace/project/src/vendor/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php:1019
Stack trace:
#0 /workspace/project/src/vendor/qiniu/php-sdk/src/Qiniu/Storage/BucketManager.php(608): Qiniu\Storage\BucketManager->rsGet('project-private-...', '/stat/xxxxx...')
#1 /workspace/project/src/backend/components/Qiniu.php(135): Qiniu\Storage\BucketManager->stat('project-private-...', '\xE6\x9C\x83\xE5\x93\xA1\xE5\xB0\x8E\xE5\x87\xBA_20...')
#2 /workspace/project/src/backend/utils/ExcelUtil.php(336): backend\components\Qiniu->test('\xE6\x9C\x83\xE5\x93\xA1\xE5\xB0\x8E\xE5\x87\xBA_20...')
之后还有,但是不方便展示

麻烦帮忙看下

相关信息

  • SDK 版本:v7.7.0
  • 框架版本:Yii 2.0.45
@lihsai0
Copy link
Collaborator

lihsai0 commented Jan 13, 2023

@jeanli-mai

image

您好,久等了,未能复现。

具体代码:

use Qiniu\Auth;
use Qiniu\Storage\BucketManager;

$accessKey = getenv('QINIU_ACCESS_KEY');
$secretKey = getenv('QINIU_SECRET_KEY');
$bucket = getenv('QINIU_TEST_BUCKET');
$key = "qiniu.mp4";

$auth = new Auth($accessKey, $secretKey);
$bucketMgr = new BucketManager($auth);

list($ret, $err) = $bucketMgr->stat($bucket, $key);
if ($err != null) {
    var_dump($err);
} else {
    var_dump($ret);
}

输出为:

array(6) {
  ["fsize"]=>
  int(25538648)
  ["hash"]=>
  string(28) "lhsawSRA9-0L8b0s-cXmojaMhGqn"
  ["md5"]=>
  string(32) "3e3a14fd770889162c4c5b94b7994cae"
  ["mimeType"]=>
  string(9) "video/mp4"
  ["putTime"]=>
  int(16735803257165241)
  ["type"]=>
  int(0)
}

针对您的错误信息,可以看下 var_dump($bucketMgr); 的输出中是否有 ["config":"Qiniu\Storage\BucketManager":private]=>object(Qiniu\Config)

另外,试下手动实例化一个 Config?

+ use Qiniu\Config;

...

+ $config = new Config();
- $bucketMgr = new BucketManager($auth);
+ $bucketManager = new BucketManager($auth, $config);

@jeanli-mai
Copy link
Author

已解决,原因是 PHP pgcache 没有清理掉,重启一下 supervisor 就可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants