分段上传没有有效载荷

时间:2018-06-26 09:54:46

标签: file-upload electron multipartform-data chromium

我正在尝试从我的javascript应用程序进行分段上传,它在chrome浏览器中可以正常工作,但是在电子版中运行时不会出现错误。 我找不到信息,为什么它不能在电子中失效,但是也许你们中有些人有想法? :)

var fileContent = new Uint8Array([64,65,66,67]);
var fileBlob = new Blob([fileContent], {type: 'application/octet-stream'});  
var data = new FormData();
data.set('file', fileBlob, 'blob.bin');  
fetch('http://my.end.point', {
  method: 'POST',
  body: data
});

当我在Chrome中运行该代码时,可以在“网络”标签中看到4字节有效负载,并且我的端点接收到4字节。如果我在电子方面也这样做,则“网络”选项卡中的有效负载为空,并且端点接收到缺少有效负载的多部分请求。我还尝试使用XMLHttpRequest而不是fetch,但这显示出完全相同的行为。

从电子内部请求有效载荷:

------WebKitFormBoundaryNXzPiiAvBttdDATr
Content-Disposition: form-data; name="file"; filename="blob.bin"
Content-Type: application/octet-stream


------WebKitFormBoundaryNXzPiiAvBttdDATr--

通过Chrome浏览器请求有效负载:

------WebKitFormBoundarywTEtXn4z3NFt3sAb
Content-Disposition: form-data; name="file"; filename="blob.bin"
Content-Type: application/octet-stream

@ABC
------WebKitFormBoundarywTEtXn4z3NFt3sAb--

有人知道,为什么它不能在电子内部起作用?

0 个答案:

没有答案
相关问题