本文整理汇总了PHP中S3::useExceptions方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::useExceptions方法的具体用法?PHP S3::useExceptions怎么用?PHP S3::useExceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::useExceptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setExceptions
/**
* Set the error mode to exceptions
*
* @param boolean $enabled Enable exceptions
* @return void
*/
public static function setExceptions($enabled = true)
{
self::$useExceptions = $enabled;
}
示例2: publish_to_s3
/**
* Publish to AWS S3 bucket
*
* @return boolean|WP_Error
*/
public function publish_to_s3($bucket, $aws_access_key_id, $aws_secret_access_key)
{
$directory_iterator = new RecursiveDirectoryIterator($this->archive_dir, RecursiveDirectoryIterator::SKIP_DOTS);
$recursive_iterator = new RecursiveIteratorIterator($directory_iterator, RecursiveIteratorIterator::SELF_FIRST);
S3::$useExceptions = true;
$s3 = new S3($aws_access_key_id, $aws_secret_access_key, false, 's3-eu-west-1.amazonaws.com');
foreach ($recursive_iterator as $item) {
if (!$item->isDir()) {
$path = $recursive_iterator->getSubPathName();
try {
$s3->putObject(S3::inputFile($item->getRealPath()), $bucket, $path, S3::ACL_PUBLIC_READ);
} catch (any $err) {
return new WP_Error('cannot_publish_to_s3', sprintf(__("Could not publish file to S3: %s: %s", $this->slug, $err), $path));
}
}
}
return true;
}