我正在尝试发送multipart/form-data
来自 IE 的工作人员。我已经使用 Chrome、Firefox、Safari 完成了此操作formData
对象(不支持IE,我需要一个手动的)
我发送的二进制数据是 crypto-js 加密数据。和formData
我做的对象:
var enc = new Buffer(encrypted.ciphertext.toString(CryptoJS.enc.Base64), 'base64');
formData.append("userFile" , new Blob([finalEncrypted], {type: 'application/octet-binary'}), 'encrypted')
this works fine generating a multipart like this(missed some parts of it):
请求标头:
Accept:*/*
Accept-Encoding:gzip, deflate
Cache-Control:no-cache
Connection:keep-alive
Content-Length:30194
Content-Type:multipart/form-data; boundary=WebKitFormBoundary0.gjepwugw5cy58kt9
body:
--WebKitFormBoundary0.gjepwugw5cy58kt9
Content-Disposition: form-data; name="userFile"; filename="encrypted"
Content-Type: binary
所有二进制数据
--WebKitFormBoundary0.cpe3c80eodgc766r--
随说明书multipart/form-data
:
IE11 doesn't accept readAsBinaryString(deprecated)
我想避免发送 base64 编码数据(readAsDataURL)(33% 有效负载)
我发送的二进制数据是 crypto-js 加密数据。
我想:
finalEncrypted = new Buffer(encrypted.ciphertext.toString(CryptoJS.enc.Base64), 'base64');
然后在我的手动多部分中,我尝试将缓冲区转换为二进制字符串:
item.toString('binary')
多部分结果看起来如下:
--WebKitFormBoundary642013568702052
Content-Disposition: form-data; name="userfile"; filename="encrypted"
Content-Type: binary
所有二进制数据
ÐçÀôpRö3§]g7,UOÂmR¤¼ÚS"Ê÷UcíMÆÎÚà/,hy¼øsËÂú@WcGvºÆÞ²i¨¬Ç~÷®}éá?'é·J]þ3«áEÁÞ,4üBçðºÇª bUÈú4
T\Ãõ=òEnýR _[1J\O-ïǹ C¨\Ûøü^%éÓÁóJNÓï¹LsXâx>\aÁV×Þ^÷·{|'
在 .NET 服务器上,我们检查客户端计算的哈希值与服务器计算的哈希值。服务器回复哈希值不匹配。这让我认为我没有正确发送文件。