You are here

protected function S3fsStream::_open_read_stream in S3 File System 8.2

Initialize the stream wrapper for a read only stream.

Parameters

array $params: An array of AWS SDK for PHP Command parameters.

array $errors: Array to which encountered errors should be appended.

1 call to S3fsStream::_open_read_stream()
S3fsStream::stream_open in src/StreamWrapper/S3fsStream.php
Support for fopen(), file_get_contents(), file_put_contents() etc.

File

src/StreamWrapper/S3fsStream.php, line 1424

Class

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

Namespace

Drupal\s3fs\StreamWrapper

Code

protected function _open_read_stream($params, &$errors) {
  $this
    ->_debug("_open_read_stream({$params['Key']}) called.", TRUE);
  $client = $this->s3;
  $command = $client
    ->getCommand('GetObject', $params);
  $command['@http']['stream'] = TRUE;
  $result = $client
    ->execute($command);
  $this->size = $result['ContentLength'];
  $this->body = $result['Body'];

  // Wrap the body in a caching entity body if seeking is allowed

  //if ($params('seekable') && !$this->body->isSeekable()) {
  $this->body = new CachingStream($this->body);

  // }
  return TRUE;
}