Skip to content

Issue with S3 + Encryption on file rename #62

Description

@hardikaspl

I have faced file rename issue when encryption is set as 'null' like following:

//servocoder/richfilemanager-php/src/Repository/S3/StorageHelper.php
public $encryption = null;

//servocoder/richfilemanager-php/src/Repository/S3/Storage.php
public function copyItem($source, $target, $remove = false)
 {
     $context = stream_context_create([
         's3' => array_merge($source->getAclParams(), [
             'ServerSideEncryption' => $this->s3->encryption,
         ]),
     ]);

     $copied = copy($source->getAbsolutePath(), $target->getAbsolutePath(), $context);

     if ($copied && $remove === true) {
         $this->s3->delete($source->getDynamicPath());
     }

     return $copied;
 }

So, when $this->s3->encryption is 'null' it does not copy the file and it eventually deletes the source file as per following:

   if ($copied && $remove === true) {
       $this->s3->delete($source->getDynamicPath());
   }

But if i remove 'ServerSideEncryption' parameter or if i set public $encryption = 'AES256'; it works. like following:

$context = stream_context_create([
  's3' => array_merge($source->getAclParams(), [
    // 'ServerSideEncryption' => $this->s3->encryption,
   ]),
]);

Or

public $encryption = 'AES256';

$context = stream_context_create([
  's3' => array_merge($source->getAclParams(), [
    'ServerSideEncryption' => $this->s3->encryption,
   ]),
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions