• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FileBackend类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: stream

 /**
  * Stream a file to the browser, adding all the headings and fun stuff.
  * Headers sent include: Content-type, Content-Length, Last-Modified,
  * and Content-Disposition.
  *
  * @param string $fname Full name and path of the file to stream
  * @param array $headers Any additional headers to send
  * @param bool $sendErrors Send error messages if errors occur (like 404)
  * @throws MWException
  * @return bool Success
  */
 public static function stream($fname, $headers = array(), $sendErrors = true)
 {
     wfProfileIn(__METHOD__);
     if (FileBackend::isStoragePath($fname)) {
         // sanity
         wfProfileOut(__METHOD__);
         throw new MWException(__FUNCTION__ . " given storage path '{$fname}'.");
     }
     wfSuppressWarnings();
     $stat = stat($fname);
     wfRestoreWarnings();
     $res = self::prepareForStream($fname, $stat, $headers, $sendErrors);
     if ($res == self::NOT_MODIFIED) {
         $ok = true;
         // use client cache
     } elseif ($res == self::READY_STREAM) {
         wfProfileIn(__METHOD__ . '-send');
         $ok = readfile($fname);
         wfProfileOut(__METHOD__ . '-send');
     } else {
         $ok = false;
         // failed
     }
     wfProfileOut(__METHOD__);
     return $ok;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:37,代码来源:StreamFile.php


示例2: assertBackendPathsConsistent

 function assertBackendPathsConsistent(array $paths)
 {
     if ($this->backend instanceof FileBackendMultiWrite) {
         $status = $this->backend->consistencyCheck($paths);
         $this->assertGoodStatus($status, "Files synced: " . implode(',', $paths));
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:7,代码来源:FileBackendTest.php


示例3: __construct

 /**
  * Construct a proxy backend that consists of several internal backends.
  * Additional $config params include:
  *     'backends'    : Array of backend config and multi-backend settings.
  *                     Each value is the config used in the constructor of a
  *                     FileBackendStore class, but with these additional settings:
  *                         'class'         : The name of the backend class
  *                         'isMultiMaster' : This must be set for one backend.
  *     'syncChecks'  : Integer bitfield of internal backend sync checks to perform.
  *                     Possible bits include self::CHECK_SIZE and self::CHECK_TIME.
  *                     The checks are done before allowing any file operations.
  * @param $config Array
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     $namesUsed = array();
     // Construct backends here rather than via registration
     // to keep these backends hidden from outside the proxy.
     foreach ($config['backends'] as $index => $config) {
         $name = $config['name'];
         if (isset($namesUsed[$name])) {
             // don't break FileOp predicates
             throw new MWException("Two or more backends defined with the name {$name}.");
         }
         $namesUsed[$name] = 1;
         if (!isset($config['class'])) {
             throw new MWException('No class given for a backend config.');
         }
         $class = $config['class'];
         $this->backends[$index] = new $class($config);
         if (!empty($config['isMultiMaster'])) {
             if ($this->masterIndex >= 0) {
                 throw new MWException('More than one master backend defined.');
             }
             $this->masterIndex = $index;
         }
     }
     if ($this->masterIndex < 0) {
         // need backends and must have a master
         throw new MWException('No master backend defined.');
     }
     $this->syncChecks = isset($config['syncChecks']) ? $config['syncChecks'] : self::CHECK_SIZE;
 }
开发者ID:amjadtbssm,项目名称:spring-website,代码行数:44,代码来源:FileBackendMultiWrite.php


示例4: __construct

 /**
  * Sets up the file object
  *
  * @param $path string Path to temporary file on local disk
  * @throws MWException
  */
 public function __construct($path)
 {
     if (FileBackend::isStoragePath($path)) {
         throw new MWException(__METHOD__ . " given storage path `{$path}`.");
     }
     $this->path = $path;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:13,代码来源:FSFile.php


示例5: getPropsFromPath

 /**
  * Get an associative array containing information about
  * a file with the given storage path.
  *
  * Resulting array fields include:
  *   - fileExists
  *   - size (filesize in bytes)
  *   - mime (as major/minor)
  *   - media_type (value to be used with the MEDIATYPE_xxx constants)
  *   - metadata (handler specific)
  *   - sha1 (in base 36)
  *   - width
  *   - height
  *   - bits (bitrate)
  *   - file-mime
  *   - major_mime
  *   - minor_mime
  *
  * @param string $path Filesystem path to a file
  * @param string|bool $ext The file extension, or true to extract it from the filename.
  *             Set it to false to ignore the extension.
  * @return array
  * @since 1.28
  */
 public function getPropsFromPath($path, $ext)
 {
     $fsFile = new FSFile($path);
     $info = $this->newPlaceholderProps();
     $info['fileExists'] = $fsFile->exists();
     if ($info['fileExists']) {
         $info['size'] = $fsFile->getSize();
         // bytes
         $info['sha1'] = $fsFile->getSha1Base36();
         # MIME type according to file contents
         $info['file-mime'] = $this->magic->guessMimeType($path, false);
         # Logical MIME type
         $ext = $ext === true ? FileBackend::extensionFromPath($path) : $ext;
         $info['mime'] = $this->magic->improveTypeFromExtension($info['file-mime'], $ext);
         list($info['major_mime'], $info['minor_mime']) = File::splitMime($info['mime']);
         $info['media_type'] = $this->magic->getMediaType($path, $info['mime']);
         # Height, width and metadata
         $handler = MediaHandler::getHandler($info['mime']);
         if ($handler) {
             $info['metadata'] = $handler->getMetadata($fsFile, $path);
             /** @noinspection PhpMethodParametersCountMismatchInspection */
             $gis = $handler->getImageSize($fsFile, $path, $info['metadata']);
             if (is_array($gis)) {
                 $info = $this->extractImageSizeInfo($gis) + $info;
             }
         }
     }
     return $info;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:53,代码来源:MWFileProps.php


示例6: __construct

 /**
  * @see FileBackend::__construct()
  *
  * @param $config Array
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     $this->memCache = new EmptyBagOStuff();
     // disabled by default
     $this->cheapCache = new ProcessCacheLRU(300);
     $this->expensiveCache = new ProcessCacheLRU(5);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:13,代码来源:FileBackendStore.php


示例7: stream

 /**
  * Stream a file to the browser, adding all the headings and fun stuff.
  * Headers sent include: Content-type, Content-Length, Last-Modified,
  * and Content-Disposition.
  *
  * @param string $fname Full name and path of the file to stream
  * @param array $headers Any additional headers to send if the file exists
  * @param bool $sendErrors Send error messages if errors occur (like 404)
  * @param array $optHeaders HTTP request header map (e.g. "range") (use lowercase keys)
  * @param integer $flags Bitfield of STREAM_* constants
  * @throws MWException
  * @return bool Success
  */
 public static function stream($fname, $headers = [], $sendErrors = true, $optHeaders = [], $flags = 0)
 {
     if (FileBackend::isStoragePath($fname)) {
         // sanity
         throw new InvalidArgumentException(__FUNCTION__ . " given storage path '{$fname}'.");
     }
     $streamer = new HTTPFileStreamer($fname, ['obResetFunc' => 'wfResetOutputBuffers', 'streamMimeFunc' => [__CLASS__, 'contentTypeFromPath']]);
     return $streamer->stream($headers, $sendErrors, $optHeaders, $flags);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:22,代码来源:StreamFile.php


示例8: tearDown

 protected function tearDown()
 {
     $this->repo->cleanupBatch($this->createdFiles);
     // delete files
     foreach ($this->createdFiles as $tmp) {
         // delete dirs
         $tmp = $this->repo->resolveVirtualUrl($tmp);
         while ($tmp = FileBackend::parentStoragePath($tmp)) {
             $this->repo->getBackend()->clean(array('dir' => $tmp));
         }
     }
     parent::tearDown();
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:13,代码来源:StoreBatchTest.php


示例9: stream

 /**
  * Stream a file to the browser, adding all the headings and fun stuff.
  * Headers sent include: Content-type, Content-Length, Last-Modified,
  * and Content-Disposition.
  *
  * @param string $fname Full name and path of the file to stream
  * @param array $headers Any additional headers to send
  * @param bool $sendErrors Send error messages if errors occur (like 404)
  * @throws MWException
  * @return bool Success
  */
 public static function stream($fname, $headers = [], $sendErrors = true)
 {
     if (FileBackend::isStoragePath($fname)) {
         // sanity
         throw new MWException(__FUNCTION__ . " given storage path '{$fname}'.");
     }
     MediaWiki\suppressWarnings();
     $stat = stat($fname);
     MediaWiki\restoreWarnings();
     $res = self::prepareForStream($fname, $stat, $headers, $sendErrors);
     if ($res == self::NOT_MODIFIED) {
         $ok = true;
         // use client cache
     } elseif ($res == self::READY_STREAM) {
         $ok = readfile($fname);
     } else {
         $ok = false;
         // failed
     }
     return $ok;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:32,代码来源:StreamFile.php


示例10: execute

 public function execute()
 {
     $out = $this->mSpecial->getOutput();
     $dbr = wfGetDB(DB_SLAVE);
     $row = $dbr->selectRow('moderation', array('mod_user AS user', 'mod_user_text AS user_text', 'mod_title AS title', 'mod_stash_key AS stash_key'), array('mod_id' => $this->id), __METHOD__);
     if (!$row) {
         throw new ModerationError('moderation-edit-not-found');
     }
     $user = $row->user ? User::newFromId($row->user) : User::newFromName($row->user_text, false);
     $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash($user);
     try {
         $file = $stash->getFile($row->stash_key);
     } catch (MWException $e) {
         return $this->send404ImageNotFound();
     }
     $is_thumb = $this->mSpecial->getRequest()->getVal('thumb');
     if ($is_thumb) {
         $thumb = $file->transform(array('width' => self::THUMB_WIDTH), File::RENDER_NOW);
         if ($thumb) {
             if ($thumb->fileIsSource()) {
                 $is_thumb = false;
             } else {
                 $file = new UnregisteredLocalFile(false, $stash->repo, $thumb->getStoragePath(), false);
             }
         }
     }
     if (!$file) {
         return $this->send404ImageNotFound();
     }
     $thumb_filename = '';
     if ($is_thumb) {
         $thumb_filename .= $file->getWidth() . 'px-';
     }
     $thumb_filename .= $row->title;
     $headers = array();
     $headers[] = "Content-Disposition: " . FileBackend::makeContentDisposition('inline', $thumb_filename);
     $out->disable();
     # No HTML output (image only)
     $file->getRepo()->streamFile($file->getPath(), $headers);
 }
开发者ID:ATCARES,项目名称:mediawiki-moderation,代码行数:40,代码来源:ModerationActionShowImage.php


示例11: fileExistsBatch

 /**
  * @param array $files
  * @return array
  */
 function fileExistsBatch(array $files)
 {
     $results = [];
     foreach ($files as $k => $f) {
         if (isset($this->mFileExists[$f])) {
             $results[$k] = $this->mFileExists[$f];
             unset($files[$k]);
         } elseif (self::isVirtualUrl($f)) {
             # @todo FIXME: We need to be able to handle virtual
             # URLs better, at least when we know they refer to the
             # same repo.
             $results[$k] = false;
             unset($files[$k]);
         } elseif (FileBackend::isStoragePath($f)) {
             $results[$k] = false;
             unset($files[$k]);
             wfWarn("Got mwstore:// path '{$f}'.");
         }
     }
     $data = $this->fetchImageQuery(['titles' => implode($files, '|'), 'prop' => 'imageinfo']);
     if (isset($data['query']['pages'])) {
         # First, get results from the query. Note we only care whether the image exists,
         # not whether it has a description page.
         foreach ($data['query']['pages'] as $p) {
             $this->mFileExists[$p['title']] = $p['imagerepository'] !== '';
         }
         # Second, copy the results to any redirects that were queried
         if (isset($data['query']['redirects'])) {
             foreach ($data['query']['redirects'] as $r) {
                 $this->mFileExists[$r['from']] = $this->mFileExists[$r['to']];
             }
         }
         # Third, copy the results to any non-normalized titles that were queried
         if (isset($data['query']['normalized'])) {
             foreach ($data['query']['normalized'] as $n) {
                 $this->mFileExists[$n['from']] = $this->mFileExists[$n['to']];
             }
         }
         # Finally, copy the results to the output
         foreach ($files as $key => $file) {
             $results[$key] = $this->mFileExists[$file];
         }
     }
     return $results;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:49,代码来源:ForeignAPIRepo.php


示例12: upload

 /**
  * Upload a file and record it in the DB
  * @param string $srcPath Source storage path, virtual URL, or filesystem path
  * @param string $comment Upload description
  * @param string $pageText Text to use for the new description page,
  *   if a new description page is created
  * @param int|bool $flags Flags for publish()
  * @param array|bool $props File properties, if known. This can be used to
  *   reduce the upload time when uploading virtual URLs for which the file
  *   info is already known
  * @param string|bool $timestamp Timestamp for img_timestamp, or false to use the
  *   current time
  * @param User|null $user User object or null to use $wgUser
  * @param string[] $tags Change tags to add to the log entry and page revision.
  *   (This doesn't check $user's permissions.)
  * @return FileRepoStatus On success, the value member contains the
  *     archive name, or an empty string if it was a new file.
  */
 function upload($srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false, $user = null, $tags = array())
 {
     global $wgContLang;
     if ($this->getRepo()->getReadOnlyReason() !== false) {
         return $this->readOnlyFatalStatus();
     }
     if (!$props) {
         if ($this->repo->isVirtualUrl($srcPath) || FileBackend::isStoragePath($srcPath)) {
             $props = $this->repo->getFileProps($srcPath);
         } else {
             $props = FSFile::getPropsFromPath($srcPath);
         }
     }
     $options = array();
     $handler = MediaHandler::getHandler($props['mime']);
     if ($handler) {
         $options['headers'] = $handler->getStreamHeaders($props['metadata']);
     } else {
         $options['headers'] = array();
     }
     // Trim spaces on user supplied text
     $comment = trim($comment);
     // Truncate nicely or the DB will do it for us
     // non-nicely (dangling multi-byte chars, non-truncated version in cache).
     $comment = $wgContLang->truncate($comment, 255);
     $this->lock();
     // begin
     $status = $this->publish($srcPath, $flags, $options);
     if ($status->successCount >= 2) {
         // There will be a copy+(one of move,copy,store).
         // The first succeeding does not commit us to updating the DB
         // since it simply copied the current version to a timestamped file name.
         // It is only *preferable* to avoid leaving such files orphaned.
         // Once the second operation goes through, then the current version was
         // updated and we must therefore update the DB too.
         $oldver = $status->value;
         if (!$this->recordUpload2($oldver, $comment, $pageText, $props, $timestamp, $user, $tags)) {
             $status->fatal('filenotfound', $srcPath);
         }
     }
     $this->unlock();
     // done
     return $status;
 }
开发者ID:paladox,项目名称:2,代码行数:62,代码来源:LocalFile.php


示例13: wfMkdirParents

/**
 * Make directory, and make all parent directories if they don't exist
 *
 * @param string $dir Full path to directory to create
 * @param int $mode Chmod value to use, default is $wgDirectoryMode
 * @param string $caller Optional caller param for debugging.
 * @throws MWException
 * @return bool
 */
function wfMkdirParents($dir, $mode = null, $caller = null)
{
    global $wgDirectoryMode;
    if (FileBackend::isStoragePath($dir)) {
        // sanity
        throw new MWException(__FUNCTION__ . " given storage path '{$dir}'.");
    }
    if (!is_null($caller)) {
        wfDebug("{$caller}: called wfMkdirParents({$dir})\n");
    }
    if (strval($dir) === '' || is_dir($dir)) {
        return true;
    }
    $dir = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $dir);
    if (is_null($mode)) {
        $mode = $wgDirectoryMode;
    }
    // Turn off the normal warning, we're doing our own below
    MediaWiki\suppressWarnings();
    $ok = mkdir($dir, $mode, true);
    // PHP5 <3
    MediaWiki\restoreWarnings();
    if (!$ok) {
        //directory may have been created on another request since we last checked
        if (is_dir($dir)) {
            return true;
        }
        // PHP doesn't report the path in its warning message, so add our own to aid in diagnosis.
        wfLogWarning(sprintf("failed to mkdir \"%s\" mode 0%o", $dir, $mode));
    }
    return $ok;
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:41,代码来源:GlobalFunctions.php


示例14: testExtensionFromPath

 /**
  * @dataProvider provider_testExtensionFromPath
  */
 public function testExtensionFromPath($path, $res)
 {
     $this->assertEquals($res, FileBackend::extensionFromPath($path), "FileBackend::extensionFromPath on path '{$path}'");
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:7,代码来源:FileBackendTest.php


示例15: filesAreSame

 protected function filesAreSame(FileBackend $src, FileBackend $dst, $sPath, $dPath)
 {
     return $src->getFileSize(['src' => $sPath]) === $dst->getFileSize(['src' => $dPath]) && $src->getFileSha1Base36(['src' => $sPath]) === $dst->getFileSha1Base36(['src' => $dPath]);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:4,代码来源:syncFileBackend.php


示例16: upload

 /**
  * Upload a file and record it in the DB
  * @param string $srcPath Source storage path, virtual URL, or filesystem path
  * @param string $comment Upload description
  * @param string $pageText Text to use for the new description page,
  *   if a new description page is created
  * @param int|bool $flags Flags for publish()
  * @param array|bool $props File properties, if known. This can be used to
  *   reduce the upload time when uploading virtual URLs for which the file
  *   info is already known
  * @param string|bool $timestamp Timestamp for img_timestamp, or false to use the
  *   current time
  * @param User|null $user User object or null to use $wgUser
  *
  * @return FileRepoStatus object. On success, the value member contains the
  *     archive name, or an empty string if it was a new file.
  */
 function upload($srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false, $user = null)
 {
     global $wgContLang;
     if ($this->getRepo()->getReadOnlyReason() !== false) {
         return $this->readOnlyFatalStatus();
     }
     if (!$props) {
         wfProfileIn(__METHOD__ . '-getProps');
         if ($this->repo->isVirtualUrl($srcPath) || FileBackend::isStoragePath($srcPath)) {
             $props = $this->repo->getFileProps($srcPath);
         } else {
             $props = FSFile::getPropsFromPath($srcPath);
         }
         wfProfileOut(__METHOD__ . '-getProps');
     }
     $options = array();
     $handler = MediaHandler::getHandler($props['mime']);
     if ($handler) {
         $options['headers'] = $handler->getStreamHeaders($props['metadata']);
     } else {
         $options['headers'] = array();
     }
     // Trim spaces on user supplied text
     $comment = trim($comment);
     // truncate nicely or the DB will do it for us
     // non-nicely (dangling multi-byte chars, non-truncated version in cache).
     $comment = $wgContLang->truncate($comment, 255);
     $this->lock();
     // begin
     $status = $this->publish($srcPath, $flags, $options);
     if ($status->successCount > 0) {
         # Essentially we are displacing any existing current file and saving
         # a new current file at the old location. If just the first succeeded,
         # we still need to displace the current DB entry and put in a new one.
         if (!$this->recordUpload2($status->value, $comment, $pageText, $props, $timestamp, $user)) {
             $status->fatal('filenotfound', $srcPath);
         }
     }
     $this->unlock();
     // done
     return $status;
 }
开发者ID:spring,项目名称:spring-website,代码行数:59,代码来源:LocalFile.php


示例17: normalizeIfValidStoragePath

 /**
  * Normalize a string if it is a valid storage path
  *
  * @param $path string
  * @return string
  */
 protected static function normalizeIfValidStoragePath($path)
 {
     if (FileBackend::isStoragePath($path)) {
         $res = FileBackend::normalizeStoragePath($path);
         return $res !== null ? $res : $path;
     }
     return $path;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:14,代码来源:FileOp.php


示例18: backendFromPath

 /**
  * Get an appropriate backend object from a storage path
  *
  * @param string $storagePath
  * @return FileBackend|null Backend or null on failure
  */
 public function backendFromPath($storagePath)
 {
     list($backend, , ) = FileBackend::splitStoragePath($storagePath);
     if ($backend !== null && isset($this->backends[$backend])) {
         return $this->get($backend);
     }
     return null;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:14,代码来源:FileBackendGroup.php


示例19: doGetLocalCopyMulti

 /**
  * @see FileBackendStore::doGetLocalCopyMulti()
  * @return null|TempFSFile
  */
 protected function doGetLocalCopyMulti(array $params)
 {
     $tmpFiles = array();
     $ep = array_diff_key($params, array('srcs' => 1));
     // for error logging
     // Blindly create tmp files and stream to them, catching any exception if the file does
     // not exist. Doing a stat here is useless causes infinite loops in addMissingMetadata().
     foreach (array_chunk($params['srcs'], $params['concurrency']) as $pathBatch) {
         $cfOps = array();
         // (path => CF_Async_Op)
         foreach ($pathBatch as $path) {
             // each path in this concurrent batch
             list($srcCont, $srcRel) = $this->resolveStoragePathReal($path);
             if ($srcRel === null) {
                 $tmpFiles[$path] = null;
                 continue;
             }
             $tmpFile = null;
             try {
                 $sContObj = $this->getContainer($srcCont);
                 $obj = new CF_Object($sContObj, $srcRel, false, false);
                 // skip HEAD
                 // Get source file extension
                 $ext = FileBackend::extensionFromPath($path);
                 // Create a new temporary file...
                 $tmpFile = TempFSFile::factory('localcopy_', $ext);
                 if ($tmpFile) {
                     $handle = fopen($tmpFile->getPath(), 'wb');
                     if ($handle) {
                         $headers = $this->headersFromParams($params);
                         if (count($pathBatch) > 1) {
                             $cfOps[$path] = $obj->stream_async($handle, $headers);
                             $cfOps[$path]->_file_handle = $handle;
                             // close this later
                         } else {
                             $obj->stream($handle, $headers);
                             fclose($handle);
                         }
                     } else {
                         $tmpFile = null;
                     }
                 }
             } catch (NoSuchContainerException $e) {
                 $tmpFile = null;
             } catch (NoSuchObjectException $e) {
                 $tmpFile = null;
             } catch (CloudFilesException $e) {
                 // some other exception?
                 $tmpFile = null;
                 $this->handleException($e, null, __METHOD__, array('src' => $path) + $ep);
             }
             $tmpFiles[$path] = $tmpFile;
         }
         $batch = new CF_Async_Op_Batch($cfOps);
         $cfOps = $batch->execute();
         foreach ($cfOps as $path => $cfOp) {
             try {
                 $cfOp->getLastResponse();
             } catch (NoSuchContainerException $e) {
                 $tmpFiles[$path] = null;
             } catch (NoSuchObjectException $e) {
                 $tmpFiles[$path] = null;
             } catch (CloudFilesException $e) {
                 // some other exception?
                 $tmpFiles[$path] = null;
                 $this->handleException($e, null, __METHOD__, array('src' => $path) + $ep);
             }
             fclose($cfOp->_file_handle);
             // close open handle
         }
     }
     return $tmpFiles;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:77,代码来源:SwiftFileBackend.php


示例20: doGetLocalCopyMulti

 protected function doGetLocalCopyMulti(array $params)
 {
     $tmpFiles = array();
     $auth = $this->getAuthentication();
     $ep = array_diff_key($params, array('srcs' => 1));
     // for error logging
     // Blindly create tmp files and stream to them, catching any exception if the file does
     // not exist. Doing a stat here is useless causes infinite loops in addMissingMetadata().
     $reqs = array();
     // (path => op)
     foreach ($params['srcs'] as $path) {
         // each path in this concurrent batch
         list($srcCont, $srcRel) = $this->resolveStoragePathReal($path);
         if ($srcRel === null || !$auth) {
             $tmpFiles[$path] = null;
             continue;
         }
         // Get source file extension
         $ext = FileBackend::extensionFromPath($path);
         // Create a new temporary file...
         $tmpFile = TempFSFile::factory('localcopy_', $ext);
         if ($tmpFile) {
             $handle = fopen($tmpFile->getPath(), 'wb');
             if ($handle) {
                 $reqs[$path] = array('method' => 'GET', 'url' => $this->storageUrl($auth, $srcCont, $srcRel), 'headers' => $this->authTokenHeaders($auth) + $this->headersFromParams($params), 'stream' => $handle);
             } else {
                 $tmpFile = null;
             }
         }
         $tmpFiles[$path] = $tmpFile;
     }
     $isLatest = $this->isRGW || !empty($params['latest']);
     $opts = array('maxConnsPerHost' => $params['concurrency']);
     $reqs = $this->http->runMulti($reqs, $opts);
     foreach ($reqs as $path => $op) {
         list($rcode, $rdesc, $rhdrs, $rbody, $rerr) = $op['response'];
         fclose($op['stream']);
         // close open handle
         if ($rcode >= 200 && $rcode <= 299) {
             $size = $tmpFiles[$path] ? $tmpFiles[$path]->getSize() : 0;
             // Double check that the disk is not full/broken
             if ($size != $rhdrs['content-length']) {
                 $tmpFiles[$path] = null;
                 $rerr = "Got {$size}/{$rhdrs['content-length']} bytes";
                 $this->onError(null, __METHOD__, array('src' => $path) + $ep, $rerr, $rcode, $rdesc);
             }
             // Set the file stat process cache in passing
             $stat = $this->getStatFromHeaders($rhdrs);
             $stat['latest'] = $isLatest;
             $this->cheapCache->set($path, 'stat', $stat);
         } elseif ($rcode === 404) {
             $tmpFiles[$path] = false;
         } else {
             $tmpFiles[$path] = null;
             $this->onError(null, __METHOD__, array('src' => $path) + $ep, $rerr, $rcode, $rdesc);
         }
     }
     return $tmpFiles;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:59,代码来源:SwiftFileBackend.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FileBackendGroup类代码示例发布时间:2022-05-23
下一篇:
PHP FileAttributeKey类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap