本文整理汇总了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;
}
示例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);
}
示例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);
}