【问题标题】:Sending binary chunks to nodejs. Build file from binary将二进制块发送到 nodejs。从二进制构建文件
【发布时间】:2018-03-15 18:21:44
【问题描述】:

大家好,我坚持这一点。我希望能够通过几个XMLHttpRequest 发送文件块,并从 nodejs 接收这些部分并从该二进制文件构建初始文件。

问题是结果文件格式不正确。我猜是因为编码。

在 FE im 上使用 file.slice 将文件拆分为几个部分,这看起来很公平,因为浏览器很好地设置了 Content-Length..

在后端我使用fs.createWriteStream 写入二进制数据,但可能编码不正确..

带有重现问题说明的 repo -> https://github.com/k1r0s/node-xhr-chunked-upload

提前致谢!

【问题讨论】:

    标签: javascript node.js ajax xmlhttprequest


    【解决方案1】:

    错误是因为我将缓冲区转换为字符串

    https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/

    我意识到这一点,我只是将所有缓冲区连接成一个。

    https://github.com/k1r0s/node-xhr-chunked-upload/commit/a724895293bca85c254cfdfec82c3226df5e2945

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2020-02-10
      • 1970-01-01
      相关资源
      最近更新 更多