Hi everyone,
I am trying to upload a video file to a third party service called Mux using Retool. I tried two different ways and running into issues with both ways. The video file is a 45mb video file, mp4.
I receive an Upload URL from Mux through our backend server and that works fine, its the uploading part that does not seem to work.
The first way
I have a jsquery, which runs this code when I press submit after uploading the file on to retool.
let res = createUpload.data
let file = clipSelected.file
async function upload(uploadUrl, file) {
let data = atob(file.data)
const newFile = new File([data], 'clip.mp4')
const upload = UpChunk.createUpload({
// uploadUrl the upload URL generated on the server-side
endpoint: uploadUrl,
file: newFile,
chunkSize: 5120, // Uploads the file in ~5mb chunks
});
// subscribe to events
upload.on('error', err => {
console.error('๐ฅ ๐', err.detail);
});
upload.on('progress', progress => {
console.log('Uploaded', progress.detail, 'percent of this file.');
});
// subscribe to events
upload.on('success', err => {
console.log("Wrap it up, we're done here. ๐");
});
}
upload(res.url, file)
I used atob
, cause I read somewhere that Retool encodes the file and then I used the Mux UpChunk package to upload but that doesnโt work, I get an error saying the file is not a video. I tried without atob and i tried just file or file.data when making a new File, none worked.
So my question is, is there a way to prevent Retool from converting the file and keep it as a File Object. That way I do not have to do use atob
or any decoding.
The second way
I tried to use a restquery API after pressing submit. But here I run into a 413 error, saying the payload is too large. I tried both file.data and file, no luck.
If anyone knows the answer to either one of these questions that would be great.