Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with MUX #7

Open
adrienfloor opened this issue Sep 11, 2021 · 9 comments
Open

Using with MUX #7

adrienfloor opened this issue Sep 11, 2021 · 9 comments

Comments

@adrienfloor
Copy link

adrienfloor commented Sep 11, 2021

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 🙌🏼
@hossein-zare
Copy link
Owner

You're welcome.

Try console.log(error.response, error.response?.data); to get the error message.
I've not used it with Mux.

What have you passed as the size prop?

const chunk = new ChunkUpload({
    size: ???
});

Mux says Split the file into chunks that are a multiple of 256KB (256 1024 bytes). but this package requires a multiple of 3.
I'll test it with Mux and let you know about it.

@adrienfloor
Copy link
Author

Thank you very much.

I've logged the error but it is a string itself, it is not an object so error.response is undefined.

As the size property I've passed this :
size: 10095,
I also tried this :
size: 1048578, to have something closer than what Mux asks (it is also a multiple of 3)

I don't find what Mux says very clear : Split the file into chunks that are a multiple of 256KB (256 1024 bytes).
and I know the package needs multiple of 3 so I'm not sure what to do with this :(

@hossein-zare
Copy link
Owner

@adrienfloor I think you should create another issue for the chunk size (256KB) ask if there's a backdoor.
I also wanted to try the Mux APIs they're pretty confusing for me. 🤦‍♂️

@adrienfloor
Copy link
Author

adrienfloor commented Sep 11, 2021

Yah, I know ... 😅

Do you mean creating another issue on this repo ?

@hossein-zare
Copy link
Owner

hossein-zare commented Sep 11, 2021

😂 Sorry i forgot to say on upchunk

@mmcc
Copy link

mmcc commented Sep 13, 2021

👋 Hi there, Mux person here! Fwiw, I agree that the upload workflow is way harder than it should be right now, so it's on our radar and we're working on it.

That being said, currently our direct uploads are performed via a GCS resumable upload, so if anything that works with GCS works with us, and any backdoors we could mention would be backdoors on Google's side of things. The most obvious one is just to do a single PUT request, but I think that was mentioned in the UpChunk issue as not being an option (which totally makes sense).

I'll dig into this more just generally, but just to ask the question...is there any way around the multiple of 3 requirement?

@hossein-zare
Copy link
Owner

Hi @mmcc , Thanks for the clarification.

This package uses base64 for encoding, that's why i can't touch the number.
ref: https://github.com/joltup/rn-fetch-blob#file-stream

There's no way all i know.

@nikitph
Copy link

nikitph commented Mar 14, 2023

Hello. we are thinking of using mux with our Rn project. But they will be large files. Is this issue something people were able to work around?

@amosaxe
Copy link

amosaxe commented Jul 12, 2024

Hi, any advice from anyone on the above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants