getChunkString() public method

Get current upload chunk as string
public getChunkString ( ) : string
return string Chunk body
コード例 #1
0
ファイル: Generic.php プロジェクト: kakserpom/phpdaemon
 /**
  * Called when chunk of incoming file has arrived
  * @param  Input $in Input buffer
  * @param  boolean $last 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);
 }