コード例 #1
0
ファイル: AwsS3.php プロジェクト: NicolasSchmutz/cm
 public function delete($path)
 {
     $options = $this->_getOptions($path);
     try {
         $this->_client->deleteObject($options);
     } catch (\Exception $e) {
         throw new CM_Exception_Invalid('Cannot delete file `' . $path . '`: ' . $e->getMessage());
     }
 }
コード例 #2
0
ファイル: AwsS3.php プロジェクト: cargomedia/cm
 public function delete($path)
 {
     $options = $this->_getOptions($path);
     try {
         $this->_client->deleteObject($options);
     } catch (\Exception $e) {
         throw new CM_Exception_Invalid('Cannot delete file in path', null, ['path' => $path, 'originalExceptionMessage' => $e->getMessage()]);
     }
 }
コード例 #3
0
ファイル: Client.php プロジェクト: cargomedia/cm
 /**
  * @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));
         }
     }
 }
コード例 #4
0
ファイル: s3file.php プロジェクト: JoonasMelin/BotQueue
 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);
 }