错误:Google Cloud Storage上的spawnSync文件ENOENT

时间:2019-01-27 13:03:56

标签: node.js google-cloud-platform google-cloud-storage

我必须为每个上传到我的Google Cloud Storage存储桶的文件创建一个预览图像。为此,我使用了filepreview npm软件包。 上传文件后,我应该会看到带有文件预览的新图像,但这丢失了,错误日志显示:

Error: spawnSync file ENOENT
   at exports._errnoException (util.js:1020:11)
   at spawnSync (child_process.js:451:20)
   at Object.execFileSync (child_process.js:488:13)
   at Object.generate (/user_code/node_modules/filepreview/filepreview.js:41:40)
   at exports.generatePreviewImage.event (/user_code/index.js:27:22)
   at /var/tmp/worker/worker.js:770:24
   at process._tickDomainCallback (internal/process/next_tick.js:135:7)

我认为文件路径不正确。这可能是问题吗?上载的文件名为kitten.png。这是我的功能:

exports.generatePreviewImage = event => {
  const object = event.data || event; // Node 6: event.data === Node 8+: event

  const file = storage.bucket(object.bucket).file(object.name);
  const filePath = `gs://${object.bucket}/${object.name}`;
  const newFilePath = `gs://${object.bucket}/${object.name}-thumb.png`;

  console.log(`filePath: ${filePath}`); // This logs 'file: gs://my-bucket/kitten.png'
  console.log(`newFilePath: ${newFilePath}`); // This logs 'gs://my-bucket/kitten.png-thumb.png'

  return filepreview.generate(filePath, newFilePath, function(error) {
    if (error) {
      return console.log('Error is now: ', error);
    }
    console.log(`File preview is: ${newFilePath}`);
  });
}

0 个答案:

没有答案