Reputation: 95
I have an blob within Google Apps Script. How can I convert it to an base64 encoded string in order to write it to other APIs? FileReader seems not to work ...
Upvotes: 3
Views: 2845
Reputation: 1
const convertImageToDataUri = () => {
const imageUrl = 'https://i.imgur.com/6rl9Atu.png';
const blob = UrlFetchApp.fetch(imageUrl).getBlob();
const base64String = Utilities.base64Encode(blob.getBytes());
return `data:image/png;base64,${base64String}`;
};
Upvotes: 0