Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud storage 在谷歌云存储中,是否记录了WritableStream?如何等待上传?_Google Cloud Storage_Google Cloud Functions - Fatal编程技术网

Google cloud storage 在谷歌云存储中,是否记录了WritableStream?如何等待上传?

Google cloud storage 在谷歌云存储中,是否记录了WritableStream?如何等待上传?,google-cloud-storage,google-cloud-functions,Google Cloud Storage,Google Cloud Functions,我正在尝试使用谷歌云功能将视频从一个存储桶转换到另一个存储桶。 我有这个: const remoteWriteStream = bucket.file(dstFile).createWriteStream() 然后我通过管道将ffmpeg输出到它。现在,ffmpeg一完成,我就从我的GCF返回,但有时文件还不存在。我知道流在完成时“发出一个finish事件”。 我从文档中看到,createWriteStream()返回一个WritableStream,但我在该对象上找不到任何文档,因此我不

我正在尝试使用谷歌云功能将视频从一个存储桶转换到另一个存储桶。 我有这个:

  const remoteWriteStream = bucket.file(dstFile).createWriteStream()
然后我通过管道将ffmpeg输出到它。现在,ffmpeg一完成,我就从我的GCF返回,但有时文件还不存在。我知道流在完成时“发出一个
finish
事件”。
我从文档中看到,
createWriteStream()
返回一个
WritableStream
,但我在该对象上找不到任何文档,因此我不知道如何等待“finish”事件。

如果您了解节点的工作方式,那么您就了解WritableStream的工作方式。我认为JavaScript API文档在这里有点混乱。以下是File.createWriteStream的TypeScript定义:

createWriteStream(options?: CreateWriteStreamOptions): Writable;
您可以看到它实际上只是返回一个可写的,在节点中定义如下:

class Writable extends Stream implements NodeJS.WritableStream { ... }

在链接的API文档中向下滚动。示例代码就在那里。是的,有一个示例,但它没有给出WritableStream对象的API。我看到有一个“.on()”方法,但实际上它被应用于ReadableStream.pipe()返回的任何内容——而且这个pipe()方法也没有文档记录。我可以抱着希望,但我喜欢看到我在正确地使用东西。啊哈,这是缺少的一部分:它是根据(或使用)标准节点类建模的,这就是为什么它没有在那里被记录的原因。(我对服务器端JS还相当陌生,所以不知道这一点。)现在一切都有了意义。谢谢