OSS\OssClient::getObjectMeta PHP Метод

getObjectMeta() публичный Метод

获取Object的Meta信息
public getObjectMeta ( string $bucket, string $object, string $options = NULL ) : array
$bucket string bucket名称
$object string object名称
$options string 具体参考SDK文档
Результат array
    public function getObjectMeta($bucket, $object, $options = NULL)
    {
        $this->precheckCommon($bucket, $object, $options);
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD;
        $options[self::OSS_OBJECT] = $object;
        $response = $this->auth($options);
        $result = new HeaderResult($response);
        return $result->getData();
    }

Usage Example

 /**
  * Get all the meta data of a file or directory.
  *
  * @param string $path
  * @return array|false
  * @throws \OSS\Core\OssException
  */
 public function getMetadata($path)
 {
     $object = $this->applyPathPrefix($path);
     try {
         $result = $this->client->getObjectMeta($this->bucket, $object);
     } catch (OssException $e) {
         return false;
     }
     return ['type' => 'file', 'dirname' => Util::dirname($path), 'path' => $path, 'timestamp' => strtotime($result['last-modified']), 'mimetype' => $result['content-type'], 'size' => $result['content-length']];
 }
All Usage Examples Of OSS\OssClient::getObjectMeta