receive.

@param string $name
@return \Symfony\Component\HttpFoundation\File\UploadedFile

@throws \Recca0120\Upload\Exceptions\ChunkedResponseException
767437
public function receive($name)
    {
        $uploadedFile = $this->request->file($name);
        $chunks = $this->request->get('chunks');
        if (empty($chunks) === true) {
            return $uploadedFile;
        }
        $chunk = $this->request->get('chunk');

        $originalName = $this->request->get('name');
        $start = $chunk * $this->request->header('content-length');
        $uuid = $this->request->get('token');
        $completed = $chunk >= $chunks - 1;

        $chunkFile = $this->createChunkFile($originalName, $uuid);
        $chunkFile->appendStream($uploadedFile->getPathname(), $start);

        return $completed === true
            ? $chunkFile->createUploadedFile()
            : $chunkFile->throwException();
    }
1102486
protected function load($name)
    {
        if (!$this->initialized) {
            $this->initialize();
        }

        if (isset($this->cache[$name])) {
            return $this->cache[$name];
        }

        $cache = $this->cachePath ? sprintf('%s/%s.cache', $this->cachePath, sha1($name)) : false;

        if (!$cache) {

            $storage = new StringStorage($this->compile($this->loader->getSource($name), $name));

        } else {

            if (!is_file($cache) || !$this->isTemplateFresh($name, filemtime($cache))) {
                $this->writeCacheFile($cache, $this->compile($this->loader->getSource($name), $name));
            }

            $storage = new FileStorage($cache);
        }

        return $this->cache[$name] = $storage;
    }
254611
final public function get(string $name)
    {
        $service_selected = null;
        foreach ($this->services as $one => $val) {
            if ($val['name'] === $name) {
                if (!in_array($val['content']->status, array("enabled", "disabled"))) {
                    throw new Server500(new \ArrayObject(array("explain" =>
                        "Undefined status [ ".$val['content']->status." ] for ".$val['name']." service",
                        "solution" => "Please set the status [disabled] or [enabled]")));
                }
                if ($val['content']->status == "disabled") {
                    throw new Server500(new \ArrayObject(array("explain" =>
                        "The service [ ".$val['name']." ] is currently disabled ",
                        "solution" => "Please set the status [enabled] to enable the service")));
                }
                $i = $val['content']->namespace;
                $container = FrameworkContainer::getInstance();
                return ($container->get($i));
            }
        }

        throw new Server500(new \ArrayObject(array("explain" =>
            "Undefined service : $name", "solution" => "Please register the [$name] service")));
    }
121823
public function getChild($name)
    {
        $path = $this->path.'/'.$name;

        if (!file_exists($path)) {
            throw new NotFound('File could not be located');
        }
        if ('.' == $name || '..' == $name) {
            throw new Forbidden('Permission denied to . and ..');
        }
        if (is_dir($path)) {
            return new self($path, $this->acl, $this->owner);
        } else {
            return new File($path, $this->acl, $this->owner);
        }
    }
512795
public function upload($name)
        {            
            if(empty($_FILES[$name]['name'])) //上传文件为空时
            {
               $this->message($this->errors['empty']);
                
                return false;
            }
            
            $this->files = $_FILES[$name];
            
            if(!file_exists($this->savePath)) //目录不存在
            {
                $this->message($this->errors['not_exist']);
                
                return false;
            }

            if(!is_writable($this->savePath)) //目录不可写
            {
                $this->message($this->errors['unwritable']);
                
                return false;
            }

            $this->fileExt  = $this->getFileExt($this->files["name"]); //取得扩展名
            
            $this->setSeveName();
            
            return $this->moveFile();
        }
4133
public static function streamHandler($name)
    {
        $suffix = date('Y-m-d-H');
        $date = date('Y-m-d');
        $pathName = str_replace('.', '/', $name);
        $streamHandler = new StreamHandler(storage_path("logs/$date/$pathName/$name-$suffix.log"));
        $streamHandler->setFormatter(new LineFormatter(null, null, true, false));
        return $streamHandler;
    }
1077331
public static function getUploadedFile($name)
    {

        // for large file, the $_FILES may be empty so see this before checking for other updates
        $limit = SystemHelper::getFileUploadLimit();
        $contentLength = intval($_SERVER['CONTENT_LENGTH']);
        if( $limit > 0 && $contentLength > $limit && count(self::getFiles())===0){
            throw new FileUploadException('Exceeded filesize limit of ' . $limit);
        }

        $files = self::getFiles();
        $fileData = $files[$name];
        if (isset($files[$name])) {

            //check for upload errors
            if (isset($fileData['error']) && $fileData['error'] != UPLOAD_ERR_OK) {
                switch ($fileData['error']) {
                    case UPLOAD_ERR_NO_FILE:
                        throw new FileUploadException('No file sent.');
                    case UPLOAD_ERR_INI_SIZE:
                    case UPLOAD_ERR_FORM_SIZE:
                        throw new FileUploadException('Exceeded filesize limit of ' . $limit);
                    default:
                        throw new common_exception_Error('Upload fails, check errors');
                }
            }
        }
        if (!is_uploaded_file($fileData['tmp_name'])) {
            throw new common_exception_Error('Non uploaded file in filedata, potential attack');
        }
        return $fileData;
    }
320830
public function getFromInput($name = false)
    {
        if ($name) {
            $this->img       = $_FILES[$name];
            $this->handle    = new Upload($this->img);
            $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name);
        }
    }
796254
public function download(string $file, ?string $name = null, ?array $headers = [])
  {
    return Rest::download(self::url($file), $name, $headers);
  }
613403
public function flush($name = null)
    {
        if ($name !== null) {
            return $this->flowCache->remove($name);
        } else {
            return $this->flowCache->flush();
        }
    }
1339899
public function upload($name)
    {
        $instance = $this->_getInstance($name);
        require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
        $uploader = new \upload($this->request->data['Filedata']);

        if (!empty($instance->settings['extensions'])) {
            $exts = explode(',', $instance->settings['extensions']);
            $exts = array_map('trim', $exts);
            $exts = array_map('strtolower', $exts);

            if (!in_array(strtolower($uploader->file_src_name_ext), $exts)) {
                $this->_error(__d('field', 'Invalid file extension.'), 501);
            }
        }

        $response = '';
        $uploader->file_overwrite = false;
        $folder = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/");
        $url = normalizePath("/files/{$instance->settings['upload_folder']}/", '/');

        $uploader->process($folder);
        if ($uploader->processed) {
            $response = json_encode([
                'file_url' => Router::url($url . $uploader->file_dst_name, true),
                'file_size' => FileToolbox::bytesToSize($uploader->file_src_size),
                'file_name' => $uploader->file_dst_name,
                'mime_icon' => FileToolbox::fileIcon($uploader->file_src_mime),
            ]);
        } else {
            $this->_error(__d('field', 'File upload error, details: {0}', $uploader->error), 502);
        }

        $this->viewBuilder()->layout('ajax');
        $this->title(__d('field', 'Upload File'));
        $this->set(compact('response'));
    }
188630
public function file(string $file, string $name = null, bool $download = true): ResponseInterface
    {
        if (!\is_file($file)) {
            throw new \LogicException("File '$file' doesn't exist.");
        }

        $extension = \substr($file, \strrpos($file, '.') + 1);
        $this->header->set('Content-Type',
            MimeType::getMimeType($extension) ?? 'application/octet-stream'
        );

        $disposition = $download ? Header::DISPOSITION_ATTACHMENT : Header::DISPOSITION_INLINE;
        $this->header->set('Content-Disposition',
            $this->header->makeDisposition($disposition, $name, \basename($file))
        );

        $size = $length = \filesize($file);

        $this->header->set('Accept-Ranges', 'bytes');
        if (\preg_match('#^bytes=(\d*)-(\d*)\z#', $this->request->header('Range'), $matches)) {
            list(, $start, $end) = $matches;

            if ($start === '') {
                $start = \max(0, $size - $end);
                $end = $size - 1;
            } elseif ($end === '' || $end > $size - 1) {
                $end = $size - 1;
            }

            if ($end < $start) {
                return $this->empty(416); // requested range not satisfiable
            }

            $this->setStatus(206);
            $this->header->set('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $size);
            $length = $end - $start + 1;
        } else {
            $this->header->set('Content-Range', 'bytes 0-' . ($size - 1) . '/' . $size);
        }

        $this->header->set('Content-Length', $length);

        $this->app->emitter(
            $this->emitter ?? Emitter\SapiStream::class
        );

        return $this->response(
            Factory::streamFromFile($file, 'rb')
        );
    }
996086
public function download(
        $file,
        string $name = null,
        array $headers = [],
        string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT
    ) : BinaryFileResponse {
        $response = new BinaryFileResponse($file, HttpResponse::HTTP_OK, $headers, true, $disposition);

        $response->prepare(HttpRequest::createFromGlobals());

        if ( ! is_null($name)) {
            $response = $response->setContentDisposition(
                $disposition,
                $name,
                iconv('UTF-8', 'ASCII//TRANSLIT', $name)
            );
        }

        return $this->createOnly ? $response : $response->send();
    }
1275460
public function file(string $name): ?UploadedFileInterface
    {
        $array = $this->serverRequest->getUploadedFiles();

        return $array[$name] ?? Arrays::get($array, $name);
    }
444105
public function extension($name)
    {
        if (is_null($path = $this->getPathFromExtensionName($name))) {
            return false;
        }

        try {
            return $this->publish($name, $path);
        } catch (Exception $e) {
            Log::emergency($e);
            throw new FilePermissionException("Unable to publish [{$path}].");
        }
    }
925413
public function create($name)
    {
        $params = array(
            "tag" => array(
                "name" => $name
            )
        );
        $rst = $this->_request->post($this->_url . 'tags/create', $params);
        return $this->_client->rst($rst);
    }
243202
public YokeFileUpload getFile(@NotNull final String name) {
        if (files == null) {
            return null;
        }

        return files.get(name);
    }