當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LocalFile::putContents方法代碼示例

本文整理匯總了PHP中LocalFile::putContents方法的典型用法代碼示例。如果您正苦於以下問題:PHP LocalFile::putContents方法的具體用法?PHP LocalFile::putContents怎麽用?PHP LocalFile::putContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LocalFile的用法示例。


在下文中一共展示了LocalFile::putContents方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: copyFile

 public static function copyFile($params)
 {
     $apiManager = new ApiManager();
     $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $cloudspace = false;
     $cloudOrig = isset($params['cloud']['origin']) && strlen($params['cloud']['origin']) > 0 ? $params['cloud']['origin'] : null;
     $cloudDestination = isset($params['cloud']['destination']) && strlen($params['cloud']['destination']) > 0 ? $params['cloud']['destination'] : null;
     $pathCloud = "home://~" . $user->getName() . "/Cloudspaces/";
     $pathOrig = null;
     if ($cloudOrig) {
         if ($pathCloud . $cloudOrig == $params['orig']) {
             $pathOrig = "/";
         } else {
             $pathOrig = substr($params['orig'], strlen($pathCloud . $cloudOrig)) . "/";
         }
     }
     if ($cloudDestination) {
         $cloudspace = true;
     }
     $file = null;
     $isFolder = true;
     $tmpFile = null;
     $filename = null;
     $pathinfo = null;
     $pathAbsolute = null;
     if (!$params['file']['is_folder']) {
         $isFolder = false;
         $tmpFile = new LocalFile('/var/tmp/' . date('Y_m_d_H_i_s') . '_' . $user->getId());
         $pathAbsolute = AdvancedPathLib::getPhpLocalHackPath($tmpFile->getAbsolutePath());
         if (array_key_exists('id', $params['file'])) {
             $token = $_SESSION['access_token_' . $cloudOrig . '_v2'];
             $resourceUrl = null;
             if (isset($params['file']['resource_url'])) {
                 $token = new stdClass();
                 $token->key = $params['access_token_key'];
                 $token->secret = $params['access_token_secret'];
                 $resourceUrl = $params['resource_url'];
             }
             $metadata = $apiManager->downloadMetadata($token, $params['file']['id'], $pathAbsolute, $user->getId(), true, $cloudOrig, $resourceUrl);
             if ($metadata['status'] == 'KO') {
                 if ($metadata['error'] == 403) {
                     $denied = self::permissionDeniedCloud($cloudOrig);
                     $metadata['path'] = $denied['path'];
                 }
                 return $metadata;
             } else {
                 if (isset($metadata['local'])) {
                     $file = FSI::getFile($params['file']['pathEyeos']);
                     $tmpFile->putContents($file->getContents());
                 }
             }
         } else {
             $file = FSI::getFile($params['file']['path']);
             $tmpFile->putContents($file->getContents());
         }
     }
     if ($pathOrig) {
         if ($params['file']['path'] == $pathOrig) {
             $pathinfo = pathinfo($params['file']['filename']);
         }
     } else {
         if ($params['file']['parent'] == null) {
             $pathinfo = pathinfo($params['file']['filename']);
         }
     }
     if ($pathinfo) {
         $nameForCheck = $pathinfo['filename'];
         $extension = null;
         if (isset($pathinfo['extension'])) {
             $extension = $pathinfo['extension'];
             $nameForCheck .= '.' . $extension;
         }
         $number = 1;
         $newFile = FSI::getFile($params['dest'] . "/" . $nameForCheck);
         while ($newFile->exists()) {
             $futureName = array($pathinfo['filename'], $number);
             $nameForCheck = implode(' ', $futureName);
             if ($extension) {
                 $nameForCheck .= '.' . $extension;
             }
             $number++;
             $newFile = FSI::getFile($params['dest'] . "/" . $nameForCheck);
             $params['filenameChange'] = $nameForCheck;
             if (!array_key_exists('parent', $params['file'])) {
                 $params['pathChange'] = substr($params['orig'], strlen($pathCloud . $cloudOrig));
             }
         }
         $filename = $newFile->getName();
     } else {
         $filename = $params['file']['filename'];
     }
     if ($cloudspace) {
         $pathParent = substr($params['dest'], strlen($pathCloud . $cloudDestination));
         if (array_key_exists('parent', $params['file'])) {
             if (strlen($pathParent) == 0 && !$params['file']['parent']) {
                 $pathParent = '/';
             }
             if ($params['file']['parent']) {
                 $pathParent .= $params['file']['parent'];
             }
//.........這裏部分代碼省略.........
開發者ID:sebasalons,項目名稱:eyeos-u1db,代碼行數:101,代碼來源:files.php

示例2: putContents

 /**
  * NOTE: in the case of a link, the data is written to its target.
  * @param mixed $data THe data to be written to the file.
  * @param int $flags FILE_APPEND | LOCK_EX (FILE_TEXT | FILE_BINARY only for PHP 6)
  * @return int The number of bytes written to the file.
  */
 public function putContents($data, $flags = 0)
 {
     $this->checkWritePermission();
     return parent::putContents($data, $flags);
 }
開發者ID:DavidGarciaCat,項目名稱:eyeos,代碼行數:11,代碼來源:LocalFile.php


注:本文中的LocalFile::putContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。