Commit 341f61df authored by Conrad Lara's avatar Conrad Lara
Browse files

Issue #3219822: Rename hook_s3fs_rename_params_alter to hook_s3fs_copy_params_alter

parent ef85367f
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -86,10 +86,10 @@ function hook_s3fs_upload_params_alter(array &$upload_params) {
}

/**
 * Alters the S3 parameters when renaming.
 * Alters the S3 parameters when copying/renaming.
 *
 * @param array $rename_params
 *   Associative array of upload settings.
 * @param array $copy_params
 *   Associative array of copy settings.
 * @param 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,
@@ -99,16 +99,16 @@ function hook_s3fs_upload_params_alter(array &$upload_params) {
 *
 * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#copyobject
 */
function hook_s3fs_rename_alter(array &$rename_params, array $s3_key_paths) {
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.
    $rename_params['CopySourceSSECustomerAlgorithm'] = 'AES256';
    $rename_params['CopySourceSSECustomerKey'] = 'MySecureKey';
    $copy_params['CopySourceSSECustomerAlgorithm'] = 'AES256';
    $copy_params['CopySourceSSECustomerKey'] = 'MySecureKey';
  }
  if (strpos($s3_key_paths['to_key'], 'private/') !== FALSE) {
    // We should encrypt the destination file.
    $rename_params['SSECustomerAlgorithm'] = 'AES256';
    $rename_params['SSECustomerKey'] = 'MySecureSecureKey';
    $copy_params['SSECustomerAlgorithm'] = 'AES256';
    $copy_params['SSECustomerKey'] = 'MySecureSecureKey';
  }
}

+1 −1
Original line number Diff line number Diff line
@@ -873,7 +873,7 @@ class S3fsStream extends StreamWrapper implements StreamWrapperInterface {
    $options = $this->getOptions();

    // Allow other modules to alter the rename params.
    \Drupal::moduleHandler()->alter('s3fs_rename_params', $options[$this->protocol], $rename_context);
    \Drupal::moduleHandler()->alter('s3fs_copy_params', $options[$this->protocol], $rename_context);

    stream_context_set_option($this->context, $options);