createWriteStream 上的可恢复和验证 Node.js

Resumable and Validation on createWriteStream Node.js

我一直在使用 Google 云存储 api 上传一些文件。 在使用上传请求时,我 运行 遇到了一些 socket hang up 的错误。

经过一番搜索,我发现 Error: socket hang up code: 'ECONNRESET' on Google cloud storage 解决了问题:

.createWriteStream({
      resumable: false,
      validation: false,
       ...
    }

我找不到关于这些参数(resumablevalidation)以及使用它们解决我的问题的原因的任何文档。 这些参数在这种情况下如何工作?

根据reference for the Cloud Storage API for Node, the resumable property is used to force a resumable upload. Resumable uploads are helpful to bypass connection errors when uploading objects to Cloud Storage buckets. In this context, the resumable property appears useful, since ECONNRESET errors include connection timeouts。至于validate 属性,它是用来执行校验和验证的。

我还注意到您链接的线程没有使用 API 提供的 upload 方法,根据文档,它是 File.CreateWriteStream() 的包装器并且是根据 documentation and related threads.

用于上传文件的方法