You are here

protected function S3fsStream::_get_metadata_from_s3 in S3 File System 8.2

Returns the converted metadata for an object in S3.

Parameters

string $uri: The URI for the object in S3.

Return value

array An array of DB-compatible file metadata.

Throws

\Exception Any exception raised by the listObjects() S3 command will percolate out of this function.

2 calls to S3fsStream::_get_metadata_from_s3()
S3fsStream::writeUriToCache in src/StreamWrapper/S3fsStream.php
Write the file at the given URI into the metadata cache.
S3fsStream::_s3fs_get_object in src/StreamWrapper/S3fsStream.php
Try to fetch an object from the metadata cache.

File

src/StreamWrapper/S3fsStream.php, line 1505

Class

S3fsStream
Defines a Drupal s3fs (s3fs://) stream wrapper class.

Namespace

Drupal\s3fs\StreamWrapper

Code

protected function _get_metadata_from_s3($uri) {
  $this
    ->_debug("_get_metadata_from_s3({$uri}) called.", TRUE);
  $params = $this
    ->_get_params($uri);
  try {
    $result = $this->s3
      ->headObject($params);
  } catch (Aws\S3\Exception\NoSuchKeyException $e) {

    // headObject() throws this exception if the requested key doesn't exist
    // in the bucket.
    return FALSE;
  }
  return $this
    ->convertMetadata($uri, $result);
}