【问题标题】:check if file is downloaded in temp in GCF from GCS检查文件是否从 GCS 在 GCF 中的 temp 中下载
【发布时间】:2020-12-22 04:16:27
【问题描述】:

我正在使用 GCF 制作视频编码器

将视频文件从 gcs 下载到 /tmp 并通过 ffmpeg 进行编码。

请问如何查看tmp中是否下载了文件?

我试过console.log(process.cwd()),但是tmp文件夹没有显示

exports.encodeVideo = async (req, res) => {

 mkdirp('/tmp')

 storage.bucket('video-bucket').file('raw/samplevideo.mp4').download({ 
 destination:'encoded/samplevideo.mp4' })

ffmpeg........
}

【问题讨论】:

    标签: javascript typescript ffmpeg google-cloud-functions google-cloud-storage


    【解决方案1】:

    download 方法是异步的,所以我能想到的最简单的方法是添加 then 之类的:

    ...).download({destination:'encoded/samplevideo.mp4'})
    .then ( () => console.log("done") )
    });
    

    如果您查看documentation,也可以添加回调。我认为在回调中处理错误/异常或在than 之后使用catch 方法链应该是明智的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-24
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-17
      • 1970-01-01
      • 2013-02-01
      相关资源
      最近更新 更多