0

我正在尝试将我的 Dropbox 文件夹中的图像检索到我在 Netlify 上构建的 Jekyll 中,但是使用以下代码无法读取这些图像。我认为我对内容使用了错误的转换。

dbx
  .filesListFolder({ path: "/images" })
  .then(response => {
    response.entries.forEach(entry => {
      const { name, path_lower } = entry;

      if (entry[".tag"] === "file") {
        dbx
          .filesDownload({ path: path_lower })
          .then(data => {
            const filename = path.resolve(IMAGES_DIR, name);
            const filecontents = data.fileBinary.toString("base64");

            fs.outputFile(filename, filecontents).catch(error => {
              if (error) {
                return console.log("Error: file failed to write", name, error);
              }
            });
          })
          .catch(error => {
            console.log("Error: file failed to download", name, error);
          });
      }
    });
  })

任何帮助都感激不尽。谢谢。

4

1 回答 1

0

通过更改修复

const filecontents = data.fileBinary.toString("base64");

const filecontents = data.fileBinary;
于 2019-09-26T17:34:11.160 回答