getObjectMeta() public méthode

获取Object的Meta信息
public getObjectMeta ( string $bucket, string $object, string $options = NULL ) : array
$bucket string bucket名称
$object string object名称
$options string 具体参考SDK文档
Résultat array
 /**
  * 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']];
 }
Exemple #2
0
/**
 * 获取object meta, 也就是getObjectMeta接口
 *
 * @param OssClient $ossClient OssClient实例
 * @param string $bucket 存储空间名称
 * @return null
 */
function getObjectMeta($ossClient, $bucket)
{
    $object = "oss-php-sdk-test/upload-test-object-name.txt";
    try {
        $objectMeta = $ossClient->getObjectMeta($bucket, $object);
    } catch (OssException $e) {
        printf(__FUNCTION__ . ": FAILED\n");
        printf($e->getMessage() . "\n");
        return;
    }
    print __FUNCTION__ . ": OK" . "\n";
    if (isset($objectMeta[strtolower('Content-Disposition')]) && 'attachment; filename="xxxxxx"' === $objectMeta[strtolower('Content-Disposition')]) {
        print __FUNCTION__ . ": ObjectMeta checked OK" . "\n";
    } else {
        print __FUNCTION__ . ": ObjectMeta checked FAILED" . "\n";
    }
}