Flutter using cloudflare stream tus upload got 400 error

Hi,

I’m now developing a mobile app for video uploading function using flutter(Dart).

i tried the tus upload with flutter library tus_client

there are several step below:

  1. post request to get tus upload url within https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/stream
  2. got the upload url.
  3. HEAD request return 200 status code
  4. PATCH request always return 400 error code

it worked well until step 4

But all step above worked well on tus demo with the URL: https://master.tus.io/files/

Does anyone can help or give me some directions?

Thanks a lot!

Derek

@renan and/or @zaid usually watch for Stream issues. Open a ticket so they can give it a look. be sure to post the ticket # here for easier tracking.

To contact Cloudflare Customer Support, login & go to https://dash.cloudflare.com/?account=support and select get more help. If you receive an automatic response that does not help resolve your issue, reply and indicate that you still require assistance. And, please share your ticket number here so that we can track it.

Hey @mx.09024! Are you going through the direct creator upload flow? (https://developers.cloudflare.com/stream/uploading-videos/direct-creator-uploads#using-tus-recommended-for-videos-over-200mb)

If so, check out this thread: Getting CORS using tus (Direct creator uploads) - #14 by renan

Is there any helpful information in the body of the response with 400 code?

3 Likes

hi,

thanks for your reply.

I change the uploading URL with ?direct_user=true
but now it received 502 status code in step 2

it was confused about this issue.

REQUEST HEADER

RESPONSE HEADER

i’ ve generated a ticket for this issus…

thanks for your reply

Can you email me your ticket id? zaid (at) cloudflare. Thanks!

First of all, it was grateful from your helping.

Now I solved the step 4 ERROR CODE 400 it’s because the mini chunk that stream required…

But I have another questions while I adopted direct creator upload

Scenario I:(direct creator upload)

SEND POST request
https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream?direct_user=true

====> the upload url contains in ‘Location’ header is https://upload.videodelivery.net/tus/9ad9e32ec59da27c16a3f56523f78b7d?tusv2=true

i send a HEAD request carries header below, it received 502 BAD Gateway

*************************************************************************************************/
Scenario II: (NOT direct creator upload)
SEND POST request to
https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream

====> the upload url contains in ‘Location’ header is https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/media/MEDIA_ID?tusv2=true

Scenario II worked well, then video uploading will be completed with several PATCH request.

how to solve this issue.

thanks a lot

Derek

Hi. When using Direct Creator Upload with tus, there is one really important thing to keep in mind: tus should be configured to call your backend service/endpoint which returns the tokenized url. Your backend service should call the Stream API and return the tokenized url in the Location header. You should not be passing the videodelivery.net url directly to tus.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.