1.0.3 • Published 3 years ago

@garphild/googledrive-client v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Usage

Init

const { downloadFileById } = await googleApi(path.join(__dirname, 'jwt.keys.json'));

Download file from google drive

const result = await downloadFileById("XXXX-YYY", "./tmp/tmp.jpg");
/**
 * {
 *   status: "success" | "fail",
 *   message: <string> - error message
 *   err: error object
 *   filePath: <string> - path to file
 * }
 */

Promise-based:

googleApi(path.join(__dirname, 'jwt.keys.json'))
  .then((myApi) => {
    const resp = myApi.downloadFileById('15j2wx4QHnLTKMVJnwsxjSm-z7uPP2lfN', './tmp/main2.jpg');
    return resp;
  })
  .then((resp) => {
    ...
    /**
     * {
     *   status: "success" | "fail",
     *   message: <string> - error message
     *   err: error object
     *   filePath: <string> - path to file
     * }
     */
  })
  .catch((e) => {
    ...
  });