Skip to content

Commit

Permalink
fix: video upload api body and error control (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Jan 10, 2024
1 parent faf90d1 commit 97da4d1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/files-and-videos/videos-page/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 97da4d1

Please sign in to comment.