/bolt.new-ai-integrations

Bolt.new AI and Backblaze B2 Cloud Storage integration: Step-by-Step Guide 2025

Learn how to integrate Bolt.new AI with Backblaze B2 Cloud Storage using our easy step-by-step guide to streamline data management and boost efficiency.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Bolt.new AI with Backblaze B2 Cloud Storage?

 

Setting Up Dependencies in package.json

 
  • Create or open your package.json file in your Bolt.new AI project.
  • Add the following dependency entry for Backblaze B2. This tells your project which external library to use:
  • 
    {
      "dependencies": {
        "backblaze-b2": "^1.2.0"
      }
    }
      
  • Once saved, Bolt.new AI will automatically read these dependencies. No terminal commands are needed.

 

Creating a Backblaze B2 Client File

 
  • Create a new file named backblazeB2.ts in your project’s src folder (or equivalent folder where your TypeScript code is maintained).
  • This file will contain functions to authorize and interact with Backblaze B2 Cloud Storage.
  • Enter the following TypeScript code into backblazeB2.ts:
  • 
    import B2 from 'backblaze-b2';
    
    

    // Initialize the Backblaze B2 client using your environment variables.
    // Ensure these environment variables (B2KEYID and B2APPKEY) are set in Bolt.new AI's secrets.
    const b2 = new B2({
    applicationKeyId: process.env.B2KEYID,
    applicationKey: process.env.B2APPKEY,
    });

    // Function to authorize with Backblaze B2.
    export async function authorize() {
    try {
    const authResponse = await b2.authorize();
    console.log('Backblaze B2 authorized successfully');
    return authResponse;
    } catch (error) {
    console.error('Authorization error:', error);
    throw error;
    }
    }

    // Function to upload a file to a specified bucket.
    // bucketId: Your Backblaze bucket ID.
    // fileName: The name you want to assign to the file in B2.
    // fileContent: The file data in Buffer format.
    export async function uploadFile(bucketId: string, fileName: string, fileContent: Buffer) {
    try {
    // Retrieve the upload URL and token.
    const uploadUrlResponse = await b2.getUploadUrl({ bucketId });
    const { uploadUrl, authorizationToken } = uploadUrlResponse.data;

    // Upload the file.
    const response = await b2.uploadFile({
      uploadUrl,
      uploadAuthToken: authorizationToken,
      fileName,
      data: fileContent
    });
    console.log('File uploaded successfully');
    return response.data;
    

    } catch (error) {
    console.error('File upload error:', error);
    throw error;
    }
    }

 

Integrating Backblaze Functions into Your Main Code

 
  • Open your main TypeScript file (for example, index.ts or similar) in your project.
  • At the top of the file, import the Backblaze B2 functions from backblazeB2.ts:
  • 
    import { authorize, uploadFile } from './backblazeB2';
      
  • Add an initialization function to authorize with Backblaze B2 when your app starts. For example:
  • 
    async function initBackblaze() {
      try {
        await authorize();
        // Optionally, call uploadFile here or later when needed.
        // For example, to upload a file, you might do:
        // const fileBuffer = Buffer.from('your file content here');
        // await uploadFile('your-bucket-id', 'example.txt', fileBuffer);
      } catch (error) {
        console.error('Error initializing Backblaze integration:', error);
      }
    }
    
    

    initBackblaze();


  • This code ensures that your Bolt.new AI project authorizes with Backblaze B2 as soon as it runs.

 

Configuring Environment Variables in Bolt.new AI

 
  • Since Bolt.new AI doesn’t provide a terminal, set your Backblaze credentials using the platform’s secrets configuration.
  • Add the following keys with their corresponding values from your Backblaze account:
    • B2KEYID: Your Backblaze Application Key ID.
    • B2APPKEY: Your Backblaze Application Key.
  • This makes process.env.B2KEYID and process.env.B2APPKEY available to your TypeScript code.

 

Testing Your Integration

 
  • After adding the code, save all modifications in Bolt.new AI.
  • Trigger your project’s run mechanism (for example, using the “Run” button in the Bolt.new AI interface).
  • Open the console to check for the log message indicating successful authorization with Backblaze B2.
  • Implement file upload triggers (such as button clicks or API calls) in your application that invoke uploadFile to confirm that file operations work as expected.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022