本文整理汇总了PHP中kDataCenterMgr::retrieveFileFromRemoteDataCenter方法的典型用法代码示例。如果您正苦于以下问题:PHP kDataCenterMgr::retrieveFileFromRemoteDataCenter方法的具体用法?PHP kDataCenterMgr::retrieveFileFromRemoteDataCenter怎么用?PHP kDataCenterMgr::retrieveFileFromRemoteDataCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kDataCenterMgr
的用法示例。
在下文中一共展示了kDataCenterMgr::retrieveFileFromRemoteDataCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContentsByFileSync
public static function getContentsByFileSync(FileSync $file_sync, $local = true, $fetch_from_remote_if_no_local = true, $strict = true)
{
if ($local) {
$full_path = $file_sync->getFullPath();
$real_path = realpath($full_path);
if (file_exists($real_path)) {
$startTime = microtime(true);
$contents = file_get_contents($real_path);
KalturaLog::info("file was found locally at [{$real_path}] fgc took [" . (microtime(true) - $startTime) . "]");
return $contents;
} else {
KalturaLog::info("file was not found locally [{$full_path}]");
throw new kFileSyncException("Cannot find file on local disk [{$full_path}] for file sync [" . $file_sync->getId() . "]", kFileSyncException::FILE_DOES_NOT_EXIST_ON_DISK);
}
}
if ($fetch_from_remote_if_no_local) {
if (!in_array($file_sync->getDc(), kDataCenterMgr::getDcIds())) {
if ($strict) {
throw new Exception("File sync is remote - cannot get contents, id = [" . $file_sync->getId() . "]");
} else {
return null;
}
}
// if $fetch_from_remote_if_no_local is false - $file_sync shoule be null , this if is in fact redundant
// TODO - curl to the remote
$content = kDataCenterMgr::retrieveFileFromRemoteDataCenter($file_sync);
return $content;
}
}
示例2: getContentsByFileSync
public static function getContentsByFileSync(FileSync $file_sync, $local = true, $fetch_from_remote_if_no_local = true, $strict = true)
{
if ($local) {
$real_path = realpath($file_sync->getFullPath());
if (file_exists($real_path)) {
KalturaLog::log(__METHOD__ . " - file was found locally at [{$real_path}]");
return file_get_contents($real_path);
} else {
KalturaLog::log(__METHOD__ . " - file was not found locally [{$real_path}]");
if ($strict) {
throw new Exception("Cannot find file on local disk [{$real_path}] for file sync [" . $file_sync->getId() . "]");
} else {
return null;
}
}
}
if ($fetch_from_remote_if_no_local) {
// if $fetch_from_remote_if_no_local is false - $file_sync shoule be null , this if is in fact redundant
// TODO - curl to the remote
$content = kDataCenterMgr::retrieveFileFromRemoteDataCenter($file_sync);
return $content;
}
}