You are here

protected function S3fsStreamWrapper::_s3fs_get_object in S3 File System 7.2

Same name and namespace in other branches
  1. 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::_s3fs_get_object()
  2. 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::_s3fs_get_object()

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

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

3 calls to S3fsStreamWrapper::_s3fs_get_object()
S3fsStreamWrapper::getExternalUrl in ./S3fsStreamWrapper.inc
Returns a web accessible URL for the resource.
S3fsStreamWrapper::_stat in ./S3fsStreamWrapper.inc
Get the status of the file with the specified URI.
S3fsStreamWrapper::_uri_is_dir in ./S3fsStreamWrapper.inc
Determine whether the $uri is a directory.

File

./S3fsStreamWrapper.inc, line 1223
Drupal stream wrapper implementation for S3 File System.

Class

S3fsStreamWrapper
The stream wrapper class.

Code

protected function _s3fs_get_object($uri) {
  $this
    ->_debug("_s3fs_get_object({$uri}) called.", TRUE);

  // For the root directory, return metadata for a generic folder.
  if (file_uri_target($uri) == '') {
    return _s3fs_convert_metadata('/', array());
  }

  // Trim any trailing '/', in case this is a folder request.
  $uri = rtrim($uri, '/');

  // Check if this URI is in the cache.
  $metadata = $this
    ->_read_cache($uri);

  // If cache ignore is enabled, query S3 for all URIs which aren't in the
  // cache, and non-folder URIs which are.
  if (!empty($this->config['ignore_cache']) && !$metadata['dir']) {
    try {

      // If _get_metadata_from_s3() returns FALSE, the file doesn't exist.
      $metadata = $this
        ->_get_metadata_from_s3($uri);
    } catch (\Exception $e) {
      $this
        ->_debug($e
        ->getMessage());
      return $this
        ->_trigger_error($e
        ->getMessage());
    }
  }
  return $metadata;
}