Using Upload API

The upload API lets you upload files, such as images and videos, to be used within Builder.

A sample node js fetch code:

const fetch = require("node-fetch");
const fs = require('fs');

function upload_image(file) {
  // read binary data
  var bitmap = fs.readFileSync(file);
  fetch("", {
    method: "POST",
    body: bitmap,
    headers: {
     "Authorization": "Bearer builder-private-key",
     "Content-Type": "image/jpeg"
 }).then(res => {
      return res.json();
 }).then(resp => {
 }).catch((e) => console.log(e));

Sample Javascript Fetch

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer builder-private-key");
myHeaders.append("Content-Type", "image/jpeg");

var file = "<file contents here>"; // Binary data

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: file,
  redirect: 'follow'

fetch("", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
1 Like