src/Server.php
protected function handlePOST(): ResponseInterface
	{

		// If the already exists we can't create it
		if (is_file($this->file))
			return $this->response->withStatus(409);

		// Get the total upload expected length
		$length = $this->request->getHeaderLine("Upload-Length");
		if ($length === "") // Note: Some PSR7 implementations discard headers set to 0.
			return $this->response->withStatus(400);

		// Check for the size of the entire upload
		if ($this->uploadMaxFileSize > 0 && $this->uploadMaxFileSize < $length)
			return $this->response->withStatus(413);

		// Create empty cache container
		$cache         = new \stdClass();
		$cache->length = $length;

		// Extension Thunder TUS CrossCheck: get complete upload checksum
		if ($this->extCrossCheck) {
			$cache->checksum = self::parseChecksum($this->request->getHeaderLine("Upload-CrossChecksum"));
			if ($cache->checksum === false)
				return $this->response->withStatus(400);
		}

		// Create an empty file to store the upload and save the cache container
		touch($this->file);
		file_put_contents($this->file . ".cachecontainer", \json_encode($cache));

		return $this->response->withStatus(201)
		                      ->withHeader("Location", $this->location);
	}
protected function handlePOST(): ResponseInterface
	{

		// If the already exists we can't create it
		if (is_file($this->file))
			return $this->response->withStatus(409);

		// Get the total upload expected length
		$length = $this->request->getHeaderLine("Upload-Length");
		if ($length === "") // Note: Some PSR7 implementations discard headers set to 0.
			return $this->response->withStatus(400);

		// Check for the size of the entire upload
		if ($this->uploadMaxFileSize > 0 && $this->uploadMaxFileSize < $length)
			return $this->response->withStatus(413);

		// Create empty cache container
		$cache         = new \stdClass();
		$cache->length = $length;

		// Extension Thunder TUS CrossCheck: get complete upload checksum
		if ($this->extCrossCheck) {
			$cache->checksum = self::parseChecksum($this->request->getHeaderLine("Upload-CrossChecksum"));
			if ($cache->checksum === false)
				return $this->response->withStatus(400);
		}

		// Create an empty file to store the upload and save the cache container
		touch($this->file);
		file_put_contents($this->file . ".cachecontainer", \json_encode($cache));

		return $this->response->withStatus(201)
		                      ->withHeader("Location", $this->location);
	}
protected function handlePOST ( ) : ResponseInterface { // If the already exists we can't create it if ( is_file ( $ this -> file ) ) return $ this -> response -> withStatus ( 409 ) ; // Get the total upload expected length $ length = $ this -> request -> getHeaderLine ( "Upload-Length" ) ; if ( $ length === "" ) // Note: Some PSR7 implementations discard headers set to 0. return $ this -> response -> withStatus ( 400 ) ; // Check for the size of the entire upload if ( $ this -> uploadMaxFileSize > 0 && $ this -> uploadMaxFileSize < $ length ) return $ this -> response -> withStatus ( 413 ) ; // Create empty cache container $ cache = new \ stdClass ( ) ; $ cache -> length = $ length ; // Extension Thunder TUS CrossCheck: get complete upload checksum if ( $ this -> extCrossCheck ) { $ cache -> checksum = self :: parseChecksum ( $ this -> request -> getHeaderLine ( "Upload-CrossChecksum" ) ) ; if ( $ cache -> checksum === false ) return $ this -> response -> withStatus ( 400 ) ; } // Create an empty file to store the upload and save the cache container touch ( $ this -> file ) ; file_put_contents ( $ this -> file . ".cachecontainer" , \ json_encode ( $ cache ) ) ; return $ this -> response -> withStatus ( 201 ) -> withHeader ( "Location" , $ this -> location ) ; }
Handle POST requests.

Creates new files on the server and caches its expected size.

If the client uses the ThunderTUS CrossCheck extension this method will also cache the final file
checksum - the checksum of the entire file.

@return \Psr\Http\Message\ResponseInterface
Handle POST requests .