Convert File URL to Base64 data in Bubble Plugin Action

Search for a command to run...

A lottery for a $1,000 Big Lots gift card will be held for each happy customer who takes the time to complete the Big Lots survey. Utilize the official survey link provided in the article to access it and complete the form with your personal information. Following the procedure, you will be given the chance to enter to win a $1,000 gift card from Big Lots Rewards. https://biglotscomsurveywin.wiki/
I have included all the information related to how you can build the Bubble plugin in this series. Check my course on how to build plugin from scratch- https://nocodetalks.co/bubbleplugin
Function Calling is a way to receive the pre-defined JSON-type response from an OpenAI API call. If you are familiar with OpenAI API, you have observed that it returns the text only. So if you query OpenAI API to list down the list of exercises and y...
Most websites use CSS :hover for hover effects. You can see them in the stylesheet, copy them, move on. Framer doesn't do that. Framer uses a React animation library (Framer Motion) with a whileHove

https://www.youtube.com/watch?v=63Lkpw8fGAw Introduction to Xano: A No-Code Backend Solution When it comes to choosing the right backend service for your project, Xano emerges as a noteworthy contender. This video explores the various facets of Xan...
Hi Everyone, This newsletter will be a little different from the ones before. In this edition, I'm excited to launch the Xano Cohort program, which I will be running. The program will start on May 6th for 6 weeks. Why I am starting this: Whenever I...

Learn what workload units are in Bubble, how they are calculated, and discover actionable strategies to optimize and reduce your app's workload units for better performance and cost efficiency. One think before moving forward- If you are reading thi...

There are instances when you may need to access an element created within the Bubble editor. For example, in a plugin, you might want to return the number of characters a user types into an input element. Follow these steps: Step 1: Enable the "Expos...

Sometimes, you may receive a file URL that you want to convert into a base64 data string. Allow me to demonstrate the code necessary for converting a file URL to base64 using Node.js.
async function convertUrlToBase64(url) {
try {
// Fetch the file
const response = await fetch(url);
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
//return response.statusText;
}
// Read the file as ArrayBuffer
const buffer = await response.arrayBuffer();
// Convert ArrayBuffer to Base64
const base64 = arrayBufferToBase64(buffer);
return base64;
console.log("base data is",base64);
} catch (error) {
console.error('Error plugin', error);
return JSON.stringify(error);
}
}
function arrayBufferToBase64(buffer) {
let binary = '';
const bytes = new Uint8Array(buffer);
const len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return Buffer.from(binary, 'binary').toString('base64');
}
// Usage
const fileUrl = 'https://cbe979c350ab6822f70996af87670e41.cdn.bubble.io/f1695201197519x684510935426170900/fghvj.png';
var basedata= await convertUrlToBase64(fileUrl);
return {
output_data:basedata
}
That's all for this blog. Subscribe for more future updates. Thank you!
Follow me on Twitter.
Checkout My Bubble Plugin Course - Use coupon code "THEBUBBLEGROUP" at checkout for 10% discount.