-
-
Save AshikNesin/ca4ad1ff1d24c26cb228a3fb5c72e0d5 to your computer and use it in GitHub Desktop.
const base64 = 'data:image/png;base64,....' // Place your base64 url here. | |
fetch(base64) | |
.then(res => res.blob()) | |
.then(blob => { | |
const fd = new FormData(); | |
const file = new File([blob], "filename.jpeg"); | |
fd.append('image', file) | |
// Let's upload the file | |
// Don't set contentType manually → https://github.com/github/fetch/issues/505#issuecomment-293064470 | |
const API_URL = 'https://example.com/add_image' | |
fetch(API_URL, {method: 'POST', body: fd) | |
.then(res => res.json()) | |
.then(res => console.log(res)) | |
Glad it was helpful @mik4ik & @pierceh89 :)
Nice it helped! const base64 = 'data:image/png;base65,....'
your string is funny as you wrote base65 :)
@nfahrni my bad, didn't notice it before. Fixed it now, thanks :)
TypeError: Network request failed
TypeError: Network request failed
Same for me also
TypeError: Network request failed
Same here :(
Thanks for sharing
Genius, thanks.
Disgusting. Thanks.
TypeError: Network request failed
you need to create the base64 with all its structure ""data:mimeType;base64,base64data":
"data;application/pdf;base64,afdnxhfuiesfslg........"
thank you bro you saved my me
Thanks for sharing
worked for me adding type: 'image/png' :
const file = new File([blob], "filename.png", { type: 'image/png' }); fileData.append('file', file);
Thank you so much!
It helped me :)