You are here

protected function S3fsStream::getS3fsObject in S3 File System 4.0.x

Same name and namespace in other branches
  1. 8.3 src/StreamWrapper/S3fsStream.php \Drupal\s3fs\StreamWrapper\S3fsStream::getS3fsObject()

Try to fetch an object from the metadata cache.

If that file isn't in the cache, we assume it doesn't exist.

Parameters

string $uri: The uri of the resource to check.

Return value

array|bool An array if the $uri exists, otherwise FALSE.

3 calls to S3fsStream::getS3fsObject()
S3fsStream::getExternalUrl in src/StreamWrapper/S3fsStream.php
Returns a web accessible URL for the resource.
S3fsStream::isDir in src/StreamWrapper/S3fsStream.php
Determine whether the $uri is a directory.
S3fsStream::stat in src/StreamWrapper/S3fsStream.php
Get the status of the file with the specified URI.

File

src/StreamWrapper/S3fsStream.php, line 1262

Class

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

Namespace

Drupal\s3fs\StreamWrapper

Code

protected function getS3fsObject($uri) {

  // For the root directory, return metadata for a generic folder.
  if ($this->streamWrapperManager::getTarget($uri) == '') {
    return $this->s3fs
      ->convertMetadata('/', []);
  }

  // Trim any trailing '/', in case this is a folder request.
  $uri = rtrim($uri, '/');
  if (mb_strlen($uri) > S3fsServiceInterface::MAX_URI_LENGTH) {
    return FALSE;
  }

  // Check if this URI is in the cache. NOTE We do this even if cache is
  // disabled because directories do not exist in S3, only object keys.
  $metadata = $this
    ->readCache($uri);

  // If cache ignore is enabled, query S3 for all URIs that are
  // not directories.
  if (!empty($this->config['ignore_cache']) && ($metadata && !$metadata['dir'])) {

    // If getS3Metadata() returns FALSE, the file doesn't exist.
    $metadata = $this
      ->getS3Metadata($uri);
  }
  return $metadata;
}