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


PHP api_Utils::GetGoogleDriveFileInfo方法代码示例

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


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

示例1: rawFiles

 /**
  * @return bool
  */
 private function rawFiles($bDownload = true, $bThumbnail = false)
 {
     $sRawKey = (string) $this->getParamValue('RawKey', '');
     $aValues = \CApi::DecodeKeyValues($sRawKey);
     if ($bThumbnail) {
         $this->verifyCacheByKey($sRawKey);
     }
     $sHash = (string) $this->getParamValue('TenantHash', '');
     $oMin = \CApi::Manager('min');
     $mMin = $oMin->getMinByHash($sHash);
     $oAccount = null;
     if (!empty($mMin['__hash__'])) {
         $oAccount = $this->oApiUsers->getAccountById($mMin['Account']);
     } else {
         if (isset($aValues['Iframed'], $aValues['Time']) && $aValues['Iframed'] && $aValues['Time']) {
             $oAccount = $this->getAccountFromParam(true, !($aValues['Time'] > \ProjectCore\Base\Utils::iframedTimestamp()));
             if (!$oAccount->IsDefaultAccount) {
                 $iAccountId = $this->oApiUsers->getDefaultAccountId($oAccount->IdUser);
                 if (0 < $iAccountId) {
                     $oAccount = $this->oApiUsers->getAccountById($iAccountId);
                 } else {
                     throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::AuthError);
                 }
             }
         } else {
             $oAccount = $this->getDefaultAccountFromParam();
         }
     }
     $oTenant = null;
     if ($oAccount && $this->oApiTenants) {
         $oTenant = 0 < $oAccount->IdTenant ? $this->oApiTenants->getTenantById($oAccount->IdTenant) : $this->oApiTenants->getDefaultGlobalTenant();
     }
     if ($this->oApiCapability->isFilesSupported($oAccount) && $oTenant && isset($aValues['Type'], $aValues['Path'], $aValues['Name'])) {
         $mResult = false;
         $sFileName = $aValues['Name'];
         $sContentType = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
         $oFileInfo = $this->oApiFilestorage->getFileInfo($oAccount, $aValues['Type'], $aValues['Path'], $aValues['Name']);
         if ($oFileInfo->IsLink) {
             $iLinkType = \api_Utils::GetLinkType($oFileInfo->LinkUrl);
             if (isset($iLinkType)) {
                 if (\EFileStorageLinkType::GoogleDrive === $iLinkType) {
                     $oSocial = $oTenant->getSocialByName('google');
                     if ($oSocial) {
                         $oInfo = \api_Utils::GetGoogleDriveFileInfo($oFileInfo->LinkUrl, $oSocial->SocialApiKey);
                         $sFileName = isset($oInfo->title) ? $oInfo->title : $sFileName;
                         $sContentType = \MailSo\Base\Utils::MimeContentType($sFileName);
                         if (isset($oInfo->downloadUrl)) {
                             $mResult = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
                             $this->oHttp->SaveUrlToFile($oInfo->downloadUrl, $mResult);
                             rewind($mResult);
                         }
                     }
                 } else {
                     if (\EFileStorageLinkType::DropBox === $iLinkType) {
                         $oFileInfo->LinkUrl = str_replace('www.dropbox.com', 'dl.dropboxusercontent.com', $oFileInfo->LinkUrl);
                     }
                     $mResult = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
                     $sFileName = basename($oFileInfo->LinkUrl);
                     $sContentType = \MailSo\Base\Utils::MimeContentType($sFileName);
                     $this->oHttp->SaveUrlToFile($oFileInfo->LinkUrl, $mResult);
                     rewind($mResult);
                 }
             }
         } else {
             $mResult = $this->oApiFilestorage->getFile($oAccount, $aValues['Type'], $aValues['Path'], $aValues['Name']);
         }
         if (false !== $mResult) {
             if (is_resource($mResult)) {
                 $sFileName = $this->clearFileName($oFileInfo->Name, $sContentType);
                 $sContentType = \MailSo\Base\Utils::MimeContentType($sFileName);
                 $this->RawOutputHeaders($bDownload, $sContentType, $sFileName);
                 if ($bThumbnail) {
                     $this->cacheByKey($sRawKey);
                     $this->thumbResource($oAccount, $mResult, $sFileName);
                 } else {
                     \MailSo\Base\Utils::FpassthruWithTimeLimitReset($mResult);
                 }
                 @fclose($mResult);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:nsine,项目名称:webmail-lite,代码行数:87,代码来源:Actions.php

示例2: GetFiles

 public function GetFiles($oAccount, $sType = \EFileStorageTypeStr::Personal, $sPath = '', $sPattern = '')
 {
     $oDirectory = null;
     $aItems = array();
     $aResult = array();
     $oMin = $this->GetMinManager();
     if ($oAccount && $this->Init($oAccount)) {
         $oTenant = null;
         $oApiTenants = \CApi::Manager('tenants');
         if ($oApiTenants) {
             $oTenant = 0 < $oAccount->IdTenant ? $oApiTenants->GetTenantById($oAccount->IdTenant) : $oApiTenants->GetDefaultGlobalTenant();
         }
         $sRootPath = $this->getRootPath($oAccount, $sType, true);
         $oDirectory = $this->getDirectory($oAccount, $sType, $sPath);
         if ($oDirectory !== null) {
             if (!empty($sPattern) || is_numeric($sPattern)) {
                 $aItems = $oDirectory->Search($sPattern);
                 $aDirectoryInfo = $oDirectory->getChildrenProperties();
                 foreach ($aDirectoryInfo as $oDirectoryInfo) {
                     if (isset($oDirectoryInfo['Link']) && strpos($oDirectoryInfo['Name'], $sPattern) !== false) {
                         $aItems[] = new \afterlogic\DAV\FS\File($oDirectory->getPath() . '/' . $oDirectoryInfo['@Name']);
                     }
                 }
             } else {
                 $aItems = $oDirectory->getChildren();
             }
             $iThumbnailLimit = 1024 * 1024 * 2;
             // 2MB
             foreach ($aItems as $oValue) {
                 $sFilePath = str_replace($sRootPath, '', dirname($oValue->getPath()));
                 $aProps = $oValue->getProperties(array('Owner', 'Shared', 'Name', 'Link', 'LinkType'));
                 $oItem = new \CFileStorageItem();
                 $oItem->Type = $sType;
                 $oItem->TypeStr = $sType;
                 $oItem->Path = $sFilePath;
                 $oItem->Name = $oValue->getName();
                 $oItem->Id = $oValue->getName();
                 $oItem->FullPath = $oItem->Name !== '' ? $oItem->Path . '/' . $oItem->Name : $oItem->Path;
                 $sID = '';
                 if ($oValue instanceof \afterlogic\DAV\FS\Directory) {
                     $sID = $this->GenerateShareHash($oAccount, $sType, $sFilePath, $oValue->getName());
                     $oItem->IsFolder = true;
                 }
                 if ($oValue instanceof \afterlogic\DAV\FS\File) {
                     $sID = $this->GenerateShareHash($oAccount, $sType, $sFilePath, $oValue->getName());
                     $oItem->IsFolder = false;
                     $oItem->Size = $oValue->getSize();
                     $oFileInfo = null;
                     if (isset($aProps['Link'])) {
                         $oItem->IsLink = true;
                         $iLinkType = api_Utils::GetLinkType($aProps['Link']);
                         $oItem->LinkType = $iLinkType;
                         $oItem->LinkUrl = $aProps['Link'];
                         if (isset($iLinkType) && $oTenant) {
                             if (\EFileStorageLinkType::GoogleDrive === $iLinkType) {
                                 $oSocial = $oTenant->GetSocialByName('google');
                                 if ($oSocial) {
                                     $oFileInfo = \api_Utils::GetGoogleDriveFileInfo($aProps['Link'], $oSocial->SocialApiKey);
                                     if ($oFileInfo) {
                                         $oItem->Name = isset($oFileInfo->title) ? $oFileInfo->title : $oItem->Name;
                                         $oItem->Size = isset($oFileInfo->fileSize) ? $oFileInfo->fileSize : $oItem->Size;
                                     }
                                 }
                             } else {
                                 if (\EFileStorageLinkType::DropBox === $iLinkType) {
                                     $aProps['Link'] = str_replace('www.dropbox.com', 'dl.dropboxusercontent.com', $aProps['Link']);
                                 }
                                 $oItem->Name = isset($aProps['Name']) ? $aProps['Name'] : basename($aProps['Link']);
                                 $aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($aProps['Link']);
                                 $oItem->Size = $aRemoteFileInfo['size'];
                             }
                         }
                     } else {
                         $oItem->IsLink = false;
                     }
                     $oItem->LastModified = $oValue->getLastModified();
                     $oItem->ContentType = $oValue->getContentType();
                     if (!$oItem->ContentType) {
                         $oItem->ContentType = \api_Utils::MimeContentType($oItem->Name);
                     }
                     if (\CApi::GetConf('labs.allow-thumbnail', true)) {
                         if ($oItem->IsLink && $oItem->LinkType === \EFileStorageLinkType::GoogleDrive && isset($oFileInfo) && isset($oFileInfo->thumbnailLink)) {
                             $oItem->Thumb = true;
                             $oItem->ThumbnailLink = $oFileInfo->thumbnailLink;
                         } else {
                             $oItem->Thumb = $oItem->Size < $iThumbnailLimit && \api_Utils::IsGDImageMimeTypeSuppoted($oItem->ContentType, $oItem->Name);
                         }
                     }
                     $oItem->Iframed = !$oItem->IsFolder && !$oItem->IsLink && \CApi::isIframedMimeTypeSupported($oItem->ContentType, $oItem->Name);
                     $oItem->Hash = \CApi::EncodeKeyValues(array('Type' => $sType, 'Path' => $sFilePath, 'Name' => $oValue->getName(), 'FileName' => $oValue->getName(), 'MimeType' => $oItem->ContentType, 'Size' => $oValue->getSize(), 'Iframed' => $oItem->Iframed));
                 }
                 $mMin = $oMin->GetMinByID($sID);
                 $oItem->Shared = isset($aProps['Shared']) ? $aProps['Shared'] : empty($mMin['__hash__']) ? false : true;
                 $oItem->Owner = isset($aProps['Owner']) ? $aProps['Owner'] : $oAccount->Email;
                 if ($oItem && '.asc' === \strtolower(\substr(\trim($oItem->Name), -4))) {
                     $mResult = $this->GetFile($oAccount, $oItem->Type, $oItem->Path, $oItem->Name);
                     if (is_resource($mResult)) {
                         $oItem->Content = stream_get_contents($mResult);
                     }
                 }
//.........这里部分代码省略.........
开发者ID:BertLasker,项目名称:Catch-design,代码行数:101,代码来源:storage.php


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