From 97da4d1d61394cb818d46f1137d1d0f4b6f4540a Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:29:33 -0500 Subject: [PATCH] fix: video upload api body and error control (#782) --- src/files-and-videos/videos-page/data/api.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/files-and-videos/videos-page/data/api.js b/src/files-and-videos/videos-page/data/api.js index be38613447..58bae471fa 100644 --- a/src/files-and-videos/videos-page/data/api.js +++ b/src/files-and-videos/videos-page/data/api.js @@ -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,