Exemplo n.º 1
0
 public function copy($sourcePath, $targetPath)
 {
     $options = $this->_getOptions($targetPath, array('CopySource' => $this->_bucket . '/' . $this->_getAbsolutePath($sourcePath)));
     try {
         $this->_client->copyObject($options);
     } catch (Exception $e) {
         throw new CM_Exception('Cannot copy', null, ['sourcePath' => $sourcePath, 'targetPath' => $targetPath, 'originalExceptionMessage' => $e->getMessage()]);
     }
 }
Exemplo n.º 2
0
 public function copy($sourcePath, $targetPath)
 {
     $options = $this->_getOptions($targetPath, array('CopySource' => $this->_bucket . '/' . $this->_getAbsolutePath($sourcePath)));
     try {
         $this->_client->copyObject($options);
     } catch (Exception $e) {
         throw new CM_Exception('Cannot copy `' . $sourcePath . '` to `' . $targetPath . '`: ' . $e->getMessage());
     }
 }
Exemplo n.º 3
0
 /**
  * @param string   $key
  * @param DateTime $date
  */
 public function restoreByCopyingOldVersion($key, DateTime $date)
 {
     $versions = $this->getVersions($key);
     /** @var CMService_AwsS3Versioning_Response_Version $versionToRestore */
     $versionToRestore = Functional\first($versions, function (CMService_AwsS3Versioning_Response_Version $version) use($key, $date) {
         $isExactKeyMatch = $key === $version->getKey();
         $isModifiedBeforeOrAt = $date >= $version->getLastModified();
         return $isExactKeyMatch && $isModifiedBeforeOrAt;
     });
     $keepCurrentVersion = $versionToRestore && $versionToRestore->getIsLatest();
     if (!$keepCurrentVersion) {
         $hasNoPriorVersion = !$versionToRestore;
         $restoreVersionIsDeleteMarker = $versionToRestore && null === $versionToRestore->getETag() && null === $versionToRestore->getSize();
         if ($hasNoPriorVersion || $restoreVersionIsDeleteMarker) {
             $this->_client->deleteObject(array('Bucket' => $this->_bucket, 'Key' => $key));
         } else {
             $this->_client->copyObject(array('Bucket' => $this->_bucket, 'CopySource' => urlencode($this->_bucket . '/' . $key) . '?versionId=' . $versionToRestore->getId(), 'Key' => $key));
         }
     }
 }
Exemplo n.º 4
0
 public function moveTo($dstPath)
 {
     $this->client->copyObject(array('Bucket' => AMAZON_S3_BUCKET_NAME, 'Key' => $dstPath, 'CopySource' => $this->get('bucket') . "/" . $this->get('path'), 'ACL' => "public-read"));
     $this->client->deleteObject(array('Bucket' => $this->get('bucket'), 'Key' => $this->get('path')));
     $this->set('path', $dstPath);
 }