本文整理汇总了PHP中api_Utils::RemoteFileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP api_Utils::RemoteFileExists方法的具体用法?PHP api_Utils::RemoteFileExists怎么用?PHP api_Utils::RemoteFileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_Utils
的用法示例。
在下文中一共展示了api_Utils::RemoteFileExists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AjaxFilesCheckUrl
/**
* @return array
*/
public function AjaxFilesCheckUrl()
{
$oAccount = $this->GetDefaultAccount();
$mResult = false;
if ($oAccount) {
$sUrl = trim($this->getParamValue('Url', ''));
if (!empty($sUrl)) {
if (\api_Utils::GetLinkType($sUrl) === \EFileStorageLinkType::GoogleDrive) {
if ($this->oApiTenants) {
$oTenant = 0 < $oAccount->IdTenant ? $this->oApiTenants->GetTenantById($oAccount->IdTenant) : $this->oApiTenants->GetDefaultGlobalTenant();
}
$oSocial = $oTenant->GetSocialByName('google');
if ($oSocial) {
$oInfo = \api_Utils::GetGoogleDriveFileInfo($sUrl, $oSocial->SocialApiKey);
if ($oInfo) {
$mResult['Size'] = 0;
if (isset($oInfo->fileSize)) {
$mResult['Size'] = $oInfo->fileSize;
} else {
$aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
$mResult['Size'] = $aRemoteFileInfo['size'];
}
$mResult['Name'] = isset($oInfo->title) ? $oInfo->title : '';
$mResult['Thumb'] = isset($oInfo->thumbnailLink) ? $oInfo->thumbnailLink : null;
}
}
} else {
if (\api_Utils::GetLinkType($sUrl) === \EFileStorageLinkType::DropBox) {
$sUrl = str_replace('?dl=0', '', $sUrl);
}
if (\api_Utils::RemoteFileExists($sUrl)) {
$aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
$sFileExtension = \api_Utils::GetFileExtensionFromMimeContentType($aRemoteFileInfo['content-type']);
$sFileName = basename($sUrl);
$sFileExtension = \api_Utils::GetFileExtension($sFileName);
if (empty($sFileExtension)) {
$sFileExtension = \api_Utils::GetFileExtensionFromMimeContentType($aRemoteFileInfo['content-type']);
$sFileName .= '.' . $sFileExtension;
}
if ($sFileExtension === 'htm') {
$sContent = file_get_contents($sUrl);
preg_match('/<title>(.*?)<\\/title>/s', $sContent, $aTitle);
$sTitle = isset($aTitle['1']) ? trim($aTitle['1']) : '';
}
$mResult['Name'] = isset($sTitle) && strlen($sTitle) > 0 ? $sTitle : urldecode($sFileName);
$mResult['Size'] = $aRemoteFileInfo['size'];
}
}
}
}
return $this->DefaultResponse(null, __FUNCTION__, $mResult);
}