Getting 400 Bad Request From Stream API

stream

#1

Hello,
We are using https://github.com/ankitpokhrel/tus-php to upload videos to Cloudflare.
But getting Bad Request

The code snipped to send files.

public static function sendToCloudFlare($localFile)
{

    $client = new \VodApi\Tus\Client(self::API_BASE_URL, 'file',
        [
            'headers' =>
                [
                    'X-Auth-Key'   => self::API_KEY,
                    'X-Auth-Email' => '<email>'
                ]
        ]);

    $client->setApiPath('/client/v4/zones/' . self::ZONE_ID . '/media/');
    $client->setFileName(pathinfo($localFile, PATHINFO_BASENAME));

    $chunk_size = 256000;
    $file_size = filesize($localFile);
    $client->file($localFile);

    $total_sent = 0;
    while ($total_sent < $file_size) {
        $total_sent = $client->upload(min($chunk_size, $file_size - $total_sent));
        D::L(ENCODING_LOG, 'Total Sent : ' . $total_sent . '/' . $file_size);
    }


    $checksum = $client->getChecksum();
    $client->delete($checksum);

}

The response body is

RESPONSE: 400 - { “result”: null, “success”: false, “errors”: [ { “code”: 10006, “message”: “Bad Request” } ], “messages”: [ { “code”: 10006, “message”: “Invalid protocol: please use TUS for uploads (see https://tus.io/ for protocol details).”

Here is also the raw Request

 HEAD /client/v4/zones/<zone-id>/media/<media-checksum> HTTP/1.1
Host: api.cloudflare.com
User-Agent: GuzzleHttp/6.2.1 curl/7.43.0 PHP/7.2.3
X-Auth-Key: <key removed>
X-Auth-Email: <email removed>

Response

HTTP/1.1 400 Bad Request
Date: Fri, 09 Mar 2018 10:12:55 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 286
Connection: keep-alive
Set-Cookie: __cfduid=<removed cfduid>; expires=Sat, 09-Mar-19 10:12:55 GMT; path=/; domain=.cloudflare.com; HttpOnly
Strict-Transport-Security: max-age=15780000; includeSubDomains
Served-In-Seconds: 0.174
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 3f8cc4175a419cad-AMS

It seems a tus-php issue, manually added Tus-Resumable to header and the first HEAD request worked.
Now, clodflare returns a Location header
Location: https://api.cloudflare.com/client/v4/zones/<zone-id>/media/<media-id>

But, the client waits a json with data.checksum in body.