You are here

protected function S3fsStreamWrapper::_s3fs_get_object in S3 File System 7.3

Same name and namespace in other branches
  1. 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::_s3fs_get_object()
  2. 7.2 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 does not 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 S3fsStreamWrapper::_s3fs_get_object()
S3fsStreamWrapper::getExternalUrl in ./S3fsStreamWrapper.inc
Returns a web accessible URL for the resource.
S3fsStreamWrapper::_path_is_dir in ./S3fsStreamWrapper.inc
Determine whether the $uri is a directory.
S3fsStreamWrapper::_stat in ./S3fsStreamWrapper.inc
Implementation of a stat method to ensure that remote files don't fail checks when they should pass.

File

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

Class

S3fsStreamWrapper
The stream wrapper class.

Code

protected function _s3fs_get_object($uri) {

  // 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) {
      return $this
        ->_trigger_error($e
        ->getMessage());
    }
  }
  return $metadata;
}