Hello I was able to create an asset via fetch on JavaScript, but have been struggling to do a put request with fetch.
curl -X PUT -H ‘Content-Type: video/mp4’ --upload-file file_path ’ upload_url ’
What I have so far:
const data = {
asset: {
file_name: “Chukker_old_new_lowres.mp4”
}
}
const filedata = {
video : “Chukker_old_new_lowres.mp4”
}
fetch(“https://api.video.wowza.com/api/v1.8/assets”, {
body: JSON.stringify(data),
headers: {
“Content-Type”: “application/json”,
“Wsc-Access-Key”: “{ACCESS-KEY}”,
“Wsc-Api-Key”: “{API-KEY}”
},
method: “POST”
}).then(res => res.json()).then(data => {
console.log(‘Success’, data.asset.upload_url);
fetch(data.asset.upload_url, {
video: JSON.stringify(filedata),
headers: {
“Content-Type”: video/mp4,
},
method: “PUT”
})
}).catch((error) => {
console.error(‘Error:’, error);
});