Last active
August 18, 2021 14:25
-
-
Save OberdanBrito/1e1d94eb43d10c9267a29a616ba76da3 to your computer and use it in GitHub Desktop.
Exemplo de conversão de base64 para blob e upload do blob
This file contains 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
UploadImagens(Conteudo) { | |
return new Promise((resolve) => { | |
fetch(Conteudo) | |
.then(res => res.blob()) | |
.then(res => { | |
let fd = new FormData(); | |
fd.append("blob", res, `${''.uuid()}.${Conteudo.substring("data:image/".length, Conteudo.indexOf(";base64"))}`); | |
fetch(this.upload, { | |
method: 'POST', | |
body: fd | |
}) | |
.then(response => response.json()) | |
.then(response => { | |
resolve(`${this.download}${response.name}`) | |
}) | |
.catch(reason => { | |
console.debug(reason) | |
}); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment