You are here

protected function AmazonS3StreamWrapper::_amazons3_format_response in AmazonS3 7

Format returned file information from S3 into an array.

Parameters

string $uri: A string containing the uri of the resource to check.

array $response: An array containing the collective metadata for the Amazon S3 object

bool $is_dir: A boolean indicating whether this object is a directory.

Return value

array An array containing formatted metadata

1 call to AmazonS3StreamWrapper::_amazons3_format_response()
AmazonS3StreamWrapper::_amazons3_get_object in ./AmazonS3StreamWrapper.inc
Try to fetch an object from the metadata cache.

File

./AmazonS3StreamWrapper.inc, line 1319
Drupal stream wrapper implementation for Amazon S3

Class

AmazonS3StreamWrapper
@file Drupal stream wrapper implementation for Amazon S3

Code

protected function _amazons3_format_response($uri, $response, $is_dir = FALSE) {
  $metadata = array(
    'uri' => $uri,
  );
  if (isset($response['Size'])) {
    $metadata['filesize'] = $response['Size'];
  }
  if (isset($response['LastModified'])) {
    $metadata['timestamp'] = date('U', strtotime((string) $response['LastModified']));
  }
  if (isset($response['Owner']['ID'])) {
    $metadata['uid'] = (string) $response['Owner']['ID'];
  }
  if ($is_dir) {
    $metadata['dir'] = 1;

    // S_IFDIR indicating directory.
    $metadata['mode'] = 040000;
    $metadata['mode'] |= 0777;
  }
  else {
    $metadata['dir'] = 0;

    // S_IFREG indicating file.
    $metadata['mode'] = 0100000;

    // Everything is writeable.
    $metadata['mode'] |= 0777;
  }
  return $metadata;
}