Skip to content
Advertisement

Node.js – How do I upload an image to Backblaze b2?

I am getting connect Request failed with status code 400 from b2.uploadFIle()

Here’s what I tried to do:

Step 1: Download backblaze-b2 node.js library and multer(to get image file in req.body)

Step 2: Set up how I’m going to call my route in POSTMAN. I have attached an IronMan.png in my request. enter image description here

Step 3: Set up my code:

JavaScript

I used multer to get the image file from the form request and then pass it to b2.uploadFile’s data property as a buffer.

Any help would be appreciated!

Advertisement

Answer

Fixed! all I had to do was to get rid of the optional parameters in b2.uploadFile()

JavaScript
Advertisement