RichFilemanager-PHP icon indicating copy to clipboard operation
RichFilemanager-PHP copied to clipboard

Issue with S3 + Encryption on file rename

Open hardikaspl opened this issue 5 years ago • 0 comments

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,
   ]),
]);

hardikaspl avatar Jun 26 '20 14:06 hardikaspl