modules

ac-bundle-module-api-dropbox

api/dropbox.js

A module for ac-bundle-app, published by ac-bundle-module.

Available Methods: upload

upload

async function(path, data, headers) {
  if (!app.has(headers)) headers = {};
  headers["Authorization"] = "Bearer " + config.dropbox.token;
  headers["Dropbox-API-Arg"] = JSON.stringify({path: config.dropbox.folder + path});
  var result = await fetch(config.dropbox.link + "/files/upload", {
    method: "POST",
    headers: headers,
    body: data
  });
  if (result.status === 200) {
    console.log("Uploaded file to dropbox: " + config.dropbox.folder + path);
  } else {
    console.log(await result.text());
  }
}

Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *