Cant upload video, decoding error, php

Hello,

I’m having an issue to upload video using laravel framework. I always get “Decoding Error”.

    $headers = [
                'Content-Type' => 'application/json',
                'Authorization' => 'Bearer MY_TOKEN_HERE',
            ];
            $client = new Client();

            $resource = Psr7\Utils::tryFopen(storage_path('app/public/' . $model->file), 'r');
            $stream = Psr7\Utils::streamFor($resource);
            
            $uri = 'https://api.cloudflare.com/client/v4/accounts/{account_id}/stream';

            $response = $client->request('POST', $uri, [
                'headers' => $headers,
                'multipart' => [
                    'file' => [
                        'contents' => self::convert_from_latin1_to_utf8_recursively($stream->getContents()),
                        'name' => 'new video',

                    ]
                ]
            ]);

any suggestions what I’m doing wrong here?

If you are still having an issue, can you drop me an email at zaid at cloudflare.com

I believe the issue is around the content-type header or the manner in which the video data is being sent.

One way to debug this is to see what exactly your script is sending to Stream. One way to do this is to use a tool like https://webhook.site/ to observe what is being sent. A successful request would look something like this:

Happy to help you further over email.