Created
January 31, 2021 17:24
-
-
Save NickFoden/109bd073fcd7c540956468563a286d4c to your computer and use it in GitHub Desktop.
Stream Upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developers.cloudflare.com/stream/uploading-videos/upload-video-file | |
const uploadFile = async (e) => { | |
const body = new FormData(); | |
body.append("file", e.currentTarget.files[0]); | |
//Tried without this next line body.append and with it | |
body.append("", "\\"); | |
const result = await fetch( | |
"https://api.cloudflare.com/client/v4/accounts/$ACCOUNT/stream", | |
{ | |
body, | |
headers: { | |
Authorization: "Bearer $TOKEN", | |
"Content-Type": "multipart/form-data", | |
}, | |
method: "POST", | |
} | |
) | |
.then((R) => R.json()) | |
.then((M) => M) | |
.catch((e) => { | |
console.error(e); | |
return e; | |
}); | |
console.dir(result); | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment