Decoding Error 100004

The same file when uploaded from the Cloudflare backend - works fine.

Can you let us know what the “Decoding Error” means .

What mistake am I doing?

  try {
        $file      =  $request->file('file');
        $token     =  config('services.cloudflare.token');
        $account   =  config('services.cloudflare.account');
        $accountId =  config('services.cloudflare.acountId');
        $client    =  new Client();
        
        $client->request('POST', 'https://api.cloudflare.com/client/v4/accounts/'.$accountId.'/stream', [
            'headers' => [
                'X-Auth-Email' => $account,
                'X-Auth-Key' => $token,
                'Content-Type'=>'application/json',
            ],
            'multipart' => [
                'file' => [
                    'contents' => file_get_contents($file),
                    'name' => 'new-video.' . $file->getClientOriginalExtension(),
                    'headers'  => [
                        'Content-Type' => $file->getClientMimeType()
                    ]
                ]
            ]
        ]);
    }
    catch (\Exception $exception)
    {
        dd($exception);
    }

What are you using for $token? The headers you are sending are for the Global API Key. API Tokens don’t use x-auth-email, and uses Authorization: Bearer <API_TOKEN> instead of x-auth-key.

I send a guzzle request as below. but Cloudflare says it cannot decode this file.

what exactly am I doing wrong?

          $response = $client->request('POST', 'https://api.cloudflare.com/client/v4/accounts/' . $accountId . '/stream/copy', [
                    'headers' => [
                        'Authorization' => 'Bearer ' . $token,
                    ],

                    'form_params' => [
                        [
                            "url" => "https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4",
                            "meta" => [
                                "name" => "My First Stream Video"
                            ]
                        ]
                    ]

                ]);