You are here

function hook_s3fs_copy_params_alter in S3 File System 4.0.x

Same name and namespace in other branches
  1. 8.3 s3fs.api.php \hook_s3fs_copy_params_alter()

Alters the S3 parameters when copying/renaming.

Parameters

array $copy_params: Associative array of copy settings.

array $s3_key_paths: Associative array of key paths inside S3 bucket including any prefixes which might be added (e.g. s3fs-public/ for public:// files, or the S3FS Root Folder setting).

  • 'from_key': Key path for source file.
  • 'to_key': Key path for destination file.

See also

https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#co...

1 invocation of hook_s3fs_copy_params_alter()
S3fsStream::rename in src/StreamWrapper/S3fsStream.php
Support for rename().

File

./s3fs.api.php, line 102
This file contains no working PHP code.

Code

function hook_s3fs_copy_params_alter(array &$copy_params, array $s3_key_paths) {
  if (strpos($s3_key_paths['from_key'], 'private/') !== FALSE) {

    // Allow the source to be decrypted.
    $copy_params['CopySourceSSECustomerAlgorithm'] = 'AES256';
    $copy_params['CopySourceSSECustomerKey'] = 'MySecureKey';
  }
  if (strpos($s3_key_paths['to_key'], 'private/') !== FALSE) {

    // We should encrypt the destination file.
    $copy_params['SSECustomerAlgorithm'] = 'AES256';
    $copy_params['SSECustomerKey'] = 'MySecureSecureKey';
  }
}