10004 Decoding Error while uploading video to Stream

I’m attempting to upload a video from a Java application to the Cloudflare servers and I’m following these guides:

  • Upload a video file: https://developers.cloudflare.com/stream/uploading-videos/upload-video-file/
  • By using tus-java-client: https://developers.cloudflare.com/api/operations/stream-videos-initiate-video-uploads-using-tus

However, the same code that works by uploading this video file https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_2MB.mp4 to https://tusd.tusdemo.net/files, gives me the following error when I attempt the same upload to Cloudflare.

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10004,
      "message": "Decoding Error"
    }
  ],
  "messages": null
}

The source code can be checked out here: https://github.com/lealceldeiro/cloudflareuploader#run-the-app

Can you confirm the following:

  1. your tus client is configured to call your backend
  2. your backend calls Stream to request a tokenized url
  3. your backend returns the tokenized url as a header as described in the Stream and tus docs

Hey, zaid, thanks for helping me out on this!
Please, find my answers inline below:

My tus client is calling https://api.cloudflare.com/client/v4/accounts/<my_account_id>/stream/copy and there’s a request header Authorization: Bearer <my_api_token>. This token has access to Read and write to Cloudflare Stream and Images

I don’t know how to verify that.
Just to confirm, when you say backend, you mean Cloudflare backend, right?
How can I check if this call to request a tokenized URL is being performed?

I’m using the official tus-java-client (https://github.com/tus/tus-java-client) which I assume should take care of all this heavy lifting for me, but please, correct me if I’m wrong.
This is the first time I use it, so I’m not fully aware of everything going on behind the scenes here.

Also, if you could paste the links for the docs you’re mentioning, I could take a look and see if I can find something useful.

@zaid , There was an error in the endpoint I was calling previously (first I was trying to copy a video from another URL, hence the mistake).

The correct one is:

https://api.cloudflare.com/client/v4/accounts/<my_account_id>/stream

After I solved that issue, now I’m getting the following error:

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10004,
      "message": "Decoding Error"
    }
  ],
  "messages": [
    {
      "code": 10004,
      "message": "invalid character '\\x00' looking for beginning of value"
    }
  ]
}

Could this be related specifically to the video I’m trying to upload (video encoding or something similar)?

After a lot of troubleshooting, this seems to be the root cause Tus-java-client. Server returned HTTP response code: 400

Could anyone confirm what would be an appropriate way to solve this?

Cloudflare recommends the tus clients (the java one among them), but then the X-HTTP-Method-Override header is not supported by the Cloudflare backend :thinking:

Hi , i’m facing same issue
“errors”: [
{
“code”: 10004,
“message”: “Decoding Error”
}
],

The error is only throw when i upload video in server, locally it is working fine

Hello,

check whether you add all required headers:

headers: {
‘Content-Type’: ‘application/json’,
‘Tus-Resumable’: ‘1.0.0’, *REQUIRED
‘Upload-Creator’: ‘’,
‘Upload-Length’: ‘’, *REQUIRED
‘Upload-Metadata’: ‘’,
‘X-Auth-Email’: ‘’
‘Authorization’ => ‘Bearer XXXXX-TOKEN’, *REQUIRED
}

note the upload url will be returned in response header