info() public method

Example: $info = $object->info(); echo $info['size'];
See also: https://cloud.google.com/storage/docs/json_api/v1/objects/get Objects get API documentation.
public info ( array $options = [] ) : array
$options array [optional] { Configuration options. @type string $encryptionKey An AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation in order to retrieve the MD5 hash and CRC32C checksum. If provided one must also include an `encryptionKeySHA256`. @type string $encryptionKeySHA256 The SHA256 hash of the customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation in order to retrieve the MD5 hash and CRC32C checksum. If provided one must also include an `encryptionKey`. @type string $ifGenerationMatch Makes the operation conditional on whether the object's current generation matches the given value. @type string $ifGenerationNotMatch Makes the operation conditional on whether the object's current generation does not match the given value. @type string $ifMetagenerationMatch Makes the operation conditional on whether the object's current metageneration matches the given value. @type string $ifMetagenerationNotMatch Makes the operation conditional on whether the object's current metageneration does not match the given value. @type string $projection Determines which properties to return. May be either 'full' or 'noAcl'. }
return array
コード例 #1
0
 public function testGetsInfoWithReload()
 {
     $objectInfo = ['name' => 'object.txt', 'bucket' => 'bucket', 'etag' => 'ABC', 'kind' => 'storage#object'];
     $this->connection->getObject(Argument::any())->willReturn($objectInfo)->shouldBeCalledTimes(1);
     $object = new StorageObject($this->connection->reveal(), 'object.txt', 'bucket');
     $this->assertEquals($objectInfo, $object->info());
 }
コード例 #2
0
 public function testGetsInfoWithReload()
 {
     $key = base64_encode('abcd');
     $hash = base64_encode('1234');
     $bucket = 'bucket';
     $object = 'object.txt';
     $objectInfo = ['name' => 'object.txt', 'bucket' => 'bucket', 'etag' => 'ABC', 'kind' => 'storage#object'];
     $this->connection->getObject(['bucket' => $bucket, 'object' => $object, 'generation' => null, 'httpOptions' => ['headers' => ['x-goog-encryption-algorithm' => 'AES256', 'x-goog-encryption-key' => $key, 'x-goog-encryption-key-sha256' => $hash]]])->willReturn($objectInfo)->shouldBeCalledTimes(1);
     $object = new StorageObject($this->connection->reveal(), $object, $bucket);
     $this->assertEquals($objectInfo, $object->info(['encryptionKey' => $key, 'encryptionKeySHA256' => $hash]));
 }
コード例 #3
0
 /**
  * Returns a dictionary of object metadata from an object.
  *
  * @param StorageObject $object
  * @return array
  */
 protected function normaliseObject(StorageObject $object)
 {
     $name = $object->name();
     $info = $object->info();
     $isDir = substr($name, -1) === '/';
     if ($isDir) {
         $name = rtrim($name, '/');
     }
     return ['type' => $isDir ? 'dir' : 'file', 'dirname' => Util::dirname($name), 'path' => $name, 'timestamp' => strtotime($info['updated']), 'mimetype' => $info['contentType'], 'size' => $info['size']];
 }