PHPDaemon\HTTPRequest\Generic::onUploadFileChunk PHP Method

onUploadFileChunk() public method

Called when chunk of incoming file has arrived
public onUploadFileChunk ( Input $in, boolean $last = false ) : void
$in Input Input buffer
$last boolean Last?
return void
    public function onUploadFileChunk($in, $last = false)
    {
        if ($in->curPart['error'] !== UPLOAD_ERR_OK) {
            // just drop the chunk
            return;
        }
        $cb = function ($fp, $result) use($last, $in) {
            if ($last) {
                unset($in->curPart['fp']);
            }
            $this->unfreezeInput();
        };
        if ($in->writeChunkToFd($in->curPart['fp']->getFd())) {
            // We had written via internal method
            return;
        }
        // Internal method is not available, let's get chunk data into $chunk and then use File->write()
        $chunk = $in->getChunkString();
        if ($chunk === false) {
            return;
        }
        $this->freezeInput();
        $in->curPart['fp']->write($chunk, $cb);
    }