Qiniu\Storage\BucketManager::stat PHP Method

stat() public method

获取资源的元信息,但不返回文件内容
public stat ( $bucket, $key ) : array
$bucket 待获取信息资源所在的空间
$key 待获取资源的文件名
return array 包含文件信息的数组,类似: [ "hash" => "", "key" => "", "fsize" => "", "putTime" => "" ]
    public function stat($bucket, $key)
    {
        $path = '/stat/' . \Qiniu\entry($bucket, $key);
        return $this->rsGet($path);
    }

Usage Example

示例#1
0
 /**
  *   上传头像
  *   图片上传成功后做标记,渲染裁剪功能,裁剪后坐标传送给Headcut,Headcut进行裁剪,保存图片,标记。
  */
 public function actionIndex()
 {
     $accessKey = 'l5Y69nZUNTSeeqJx1LqCJP1KuLWIGU_3JVZXLzN-';
     $secretKey = '6-4HOEBkNlJpo_TuFrM9W8ZEjytRZAYjuiG0F8Df';
     $auth = new Auth($accessKey, $secretKey);
     $bucketMgr = new BucketManager($auth);
     $bucket = 'colfans-uploads-public';
     $key = 'fun.jpg';
     list($ret, $err) = $bucketMgr->stat($bucket, $key);
     echo "\n====> stat result: \n";
     if ($err !== null) {
         var_dump($err);
     } else {
         var_dump($ret);
     }
     if (!empty($_FILES['headpic'])) {
         $user = User::findByUsername(Yii::$app->user->identity->username);
         $image = UploadedFile::getInstanceByName('headpic');
         $imageName = $user->id . '_' . time() . '.' . $image->getExtension();
         if ($image->saveAs('uploads/head/' . $imageName)) {
             // file is uploaded successfully
             echo 'yes';
             die;
         } else {
             echo 'no';
             die;
         }
     } else {
         return $this->render('headupload', ['title' => '个人资料', 'category' => '账号管理', 'subcate' => '个人资料']);
     }
 }
All Usage Examples Of Qiniu\Storage\BucketManager::stat