Skip to content

Using with MUX #7

@adrienfloor

Description

@adrienfloor

Thanks again for the great work here @hossein-zare

I'm trying to use the lib to upload to MUX as direct upload but somehow I'm getting 400 bad request :
https://docs.mux.com/guides/video/upload-files-directly#if-you-dont-want-to-use-upchunk

I've added "content-length" and "content-range" headers as Mux is asking, but the catch block only sends back a text error saying "Error: Request failed with status code 400". Therefore I'm having trouble debugging because I don't know what I'm doing wrong not having the whole error object.

Here is my code :

    axios.put(muxUploadUrl, body, {
      headers: {
        "Content-Type": "multipart/form-data",
        "Accept": 'application/json',
        "Content-Length": file.headers["x-chunk-size"],
        "Content-Range": `bytes ${file.number - 1}-${file.headers["x-chunk-size"]}/${file.headers["x-file-size"]}`,
        // Customize the headers
        "x-chunk-number": file.headers["x-chunk-number"],
        "x-chunk-total-number": file.headers["x-chunk-total-number"],
        "x-chunk-size": file.headers["x-chunk-size"],
        "x-file-name": file.headers["x-file-name"],
        "x-file-size": file.headers["x-file-size"],
        "x-file-identity": file.headers["x-file-identity"]
      }
    })
      .then(response => {
        console.log('response : ', response)
      })
      .catch(error => {
        console.log( 'Upload error : ', error)
        ...
       
  Am I mistaking the headers configuration ? Should I split the file chunks in other values than the ones from the readme ?
  Have you ever tried the lib with Mux ?
  
  Thank you so much for your help 🙌🏼

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions