I am trying to add videos with react-dropzone to submit a data model via user entry and I’m currently running into some issues.
Going through the docs, it seems like a video has to be uploaded before it can be used in the writeApi>
I have tried used the uploadApi to upload a both a .mov and mp4 file but have been getting 400 (image not specified) or 500 (internal sever error) errors.
Does anyone else have any thoughts on how to add videos to a data model via user form submission?
Example snippet of attempting to use the uploadApi.
Side Note:
I have also changed the content-type to ‘video/.mp4’ & ‘video/.mov’ and that doesn’t seem to work either
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (err) => reject(err);
const attemptUpload = async (file) => {
try {
return await fetch(
`https://builder.io/api/v1/upload?test-file-name.mov`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'multipart/form-data'
},
body: file,
}
);
} catch (err) {
console.log(err);
}
}