Skip to content

Instantly share code, notes, and snippets.

@rezonn
Created August 13, 2020 04:59
Show Gist options
  • Select an option

  • Save rezonn/d3b12b59db3796240ae87b3cc07261b7 to your computer and use it in GitHub Desktop.

Select an option

Save rezonn/d3b12b59db3796240ae87b3cc07261b7 to your computer and use it in GitHub Desktop.
async function upload(canvas,url) {
let blob = await (new Promise(resolve => canvas.toBlob(resolve)));
try {
const response = await fetch(url,
{
method:'POST',
headers:{
'Content-Type':'application/octet-stream'
},
body:blob
});
} catch(e) {console.log("fetch error: "+e.message)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment