fix: video upload api body and error control (#782)

This commit is contained in:
Kristin Aoki
2024-01-10 10:29:33 -05:00
committed by GitHub
parent faf90d1fa7
commit 97da4d1d61

View File

@@ -174,18 +174,21 @@ export async function uploadVideo(
uploadFile,
edxVideoId,
) {
const formData = new FormData();
formData.append('uploaded-file', uploadFile);
const uploadErrors = [];
await fetch(uploadUrl, {
method: 'PUT',
body: formData,
headers: {
'Content-Type': 'multipart/form-data',
'Content-Disposition': `attachment; filename="${uploadFile.name}"`,
'Content-Type': uploadFile.type,
},
multipart: false,
body: uploadFile,
})
.then(async () => {
.then(async (response) => {
if (!response.ok) {
throw new Error();
}
await getAuthenticatedHttpClient()
.post(getCourseVideosApiUrl(courseId), [{
edxVideoId,