You are here

protected function S3fsStream::_get_params in S3 File System 8.2

Get the Command parameters for the specified URI.

Parameters

string $uri: The URI of the file.

Return value

array A Command parameters array, including 'Bucket', 'Key', and context parameters.

5 calls to S3fsStream::_get_params()
S3fsStream::rename in src/StreamWrapper/S3fsStream.php
Support for rename().
S3fsStream::stream_open in src/StreamWrapper/S3fsStream.php
Support for fopen(), file_get_contents(), file_put_contents() etc.
S3fsStream::unlink in src/StreamWrapper/S3fsStream.php
Support for unlink().
S3fsStream::waitUntilFileExists in src/StreamWrapper/S3fsStream.php
Wait for the specified file to exist in the bucket.
S3fsStream::_get_metadata_from_s3 in src/StreamWrapper/S3fsStream.php
Returns the converted metadata for an object in S3.

File

src/StreamWrapper/S3fsStream.php, line 1388

Class

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

Namespace

Drupal\s3fs\StreamWrapper

Code

protected function _get_params($uri) {
  $params = $this
    ->_get_options();
  unset($params['seekable']);
  unset($params['throw_exceptions']);
  $params['Bucket'] = $this->config['bucket'];
  $params['Key'] = file_uri_target($uri);
  $public_folder = !empty($this->config['public_folder']) ? $this->config['public_folder'] : 's3fs-public';
  $private_folder = !empty($this->config['private_folder']) ? $this->config['private_folder'] : 's3fs-private';

  // public:// file are all placed in the s3fs_public_folder.
  if (\Drupal::service('file_system')
    ->uriScheme($uri) == 'public') {
    $params['Key'] = "{$public_folder}/{$params['Key']}";
  }
  else {
    if (\Drupal::service('file_system')
      ->uriScheme($uri) == 'private') {
      $params['Key'] = "{$private_folder}/{$params['Key']}";
    }
  }

  // If it's set, all files are placed in the root folder.
  if (!empty($this->config['root_folder'])) {
    $params['Key'] = "{$this->config['root_folder']}/{$params['Key']}";
  }
  return $params;
}