当前位置: 首页>>代码示例>>PHP>>正文


PHP AmazonS3::if_object_exists方法代码示例

本文整理汇总了PHP中AmazonS3::if_object_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP AmazonS3::if_object_exists方法的具体用法?PHP AmazonS3::if_object_exists怎么用?PHP AmazonS3::if_object_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AmazonS3的用法示例。


在下文中一共展示了AmazonS3::if_object_exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: moveObject

 /**
  * Move a file or folder to a specific location
  *
  * @param string $from The location to move from
  * @param string $to The location to move to
  * @param string $point
  * @return boolean
  */
 public function moveObject($from, $to, $point = 'append')
 {
     $this->xpdo->lexicon->load('source');
     $success = false;
     if (substr(strrev($from), 0, 1) == '/') {
         $this->xpdo->error->message = $this->xpdo->lexicon('s3_no_move_folder', array('from' => $from));
         return $success;
     }
     if (!$this->driver->if_object_exists($this->bucket, $from)) {
         $this->xpdo->error->message = $this->xpdo->lexicon('file_err_ns') . ': ' . $from;
         return $success;
     }
     if ($to != '/') {
         if (!$this->driver->if_object_exists($this->bucket, $to)) {
             $this->xpdo->error->message = $this->xpdo->lexicon('file_err_ns') . ': ' . $to;
             return $success;
         }
         $toPath = rtrim($to, '/') . '/' . basename($from);
     } else {
         $toPath = basename($from);
     }
     $response = $this->driver->copy_object(array('bucket' => $this->bucket, 'filename' => $from), array('bucket' => $this->bucket, 'filename' => $toPath), array('acl' => AmazonS3::ACL_PUBLIC));
     $success = $response->isOK();
     if ($success) {
         $deleteResponse = $this->driver->delete_object($this->bucket, $from);
         $success = $deleteResponse->isOK();
     } else {
         $this->xpdo->error->message = $this->xpdo->lexicon('file_folder_err_rename') . ': ' . $to . ' -> ' . $from;
     }
     return $success;
 }
开发者ID:nervlin4444,项目名称:modx-cms,代码行数:39,代码来源:mods3mediasource.class.php

示例2: objectExists

 /**
  * Checks whether an object exists.
  *
  * @param string $objectPath
  *
  * @return bool
  */
 protected function objectExists($objectPath)
 {
     return $this->storage->if_object_exists($this->bucket, $objectPath);
 }
开发者ID:umanit,项目名称:LiipImagineBundle,代码行数:11,代码来源:AmazonS3Resolver.php

示例3: moveEpisodeFileToAmazon

 public function moveEpisodeFileToAmazon()
 {
     if (!$this->getAudioFile()) {
         throw new Exception("No local file to upload!");
     }
     $file_location = ProjectConfiguration::getEpisodeAudioFileLocalDirectory();
     $filename = $file_location . $this->getAudioFile();
     if (!file_exists($filename)) {
         throw new Exception("No local file to upload!");
     }
     ProjectConfiguration::registerAws();
     $s3 = new AmazonS3();
     $bucket = $this->getSubreddit()->getBucketName();
     if ($s3->if_bucket_exists($bucket)) {
         $nice_filename = $this->getNiceFilename();
         while ($s3->if_object_exists($bucket, $nice_filename)) {
             $nice_filename = $nice_filename . rand(0, 1000);
             $this->setNiceFilename($nice_filename);
         }
         $response = $s3->create_object($bucket, $this->getNiceFilename(), array('fileUpload' => $file_location . $this->getAudioFile(), 'acl' => AmazonS3::ACL_PUBLIC));
         if ($response->isOK()) {
             //$this->setRemoteUrl($s3->get_object_url($bucket,
             //                                        $this->getNiceFilename()));
             $this->setRemoteUrl('http://' . $this->getSubreddit()->getCfDomainName() . '/' . urlencode($this->getNiceFilename()));
             $this->deleteLocalFile($this->getAudioFile());
         }
     } else {
         throw new Exception("Amazon bucket '{$bucket}' does not exist!");
     }
     $this->setFileIsRemote(true);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:31,代码来源:Episode.class.php


注:本文中的AmazonS3::if_object_exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。