1

I need to save that profile picture returned from the google OAuth as base 64.

function Google_signIn(googleUser) {
    const profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());
    console.log('JSON: ' + profile._json.image.url());
}

from this function, I can get the image URL, but I want to save the image in Base64.

This is a example URL.

R0b1n
  • 513
  • 1
  • 5
  • 28
  • 2
    This is probably what you are looking for: https://stackoverflow.com/questions/6150289/how-can-i-convert-an-image-into-base64-string-using-javascript – niklhs Jan 08 '21 at 21:03
  • 1
    Why? Why not just hotlink the image? – Ouroborus Jan 09 '21 at 02:56
  • @niklhs nop, It's not what I wanted to do. I want to save that image locally. – R0b1n Jan 14 '21 at 18:53
  • @Ouroborus Because I have given option to user to login using google or just upload image to the app. – R0b1n Jan 14 '21 at 18:53
  • 1
    It's a profile image, right? They either uploaded one or they didn't. If they did upload one, link to that. If they didn't upload one, hotlink directly to the google profile image. There's no actual need to keep a local copy of the google profile image. – Ouroborus Jan 14 '21 at 22:20

0 Answers0