在Node.js中使用HTTP上传文件的方法(5)

<div>
<spanLucida Console"; font-size: 8.0pt;">// Save current protocol and host for parallel uploads</span></div>
<div>
"font-family: &apos;Lucida Console&apos;; font-size: 8pt;"><span>var</span><span> currentProtocol </span><span>= </span><span>window.</span><span>location</span><span>.</span><span>protocol</span><span>;</span></div>
<div>
"font-family: &apos;Lucida Console&apos;; font-size: 8pt;"><span>var</span><span> currentHostandPort </span><span>=</span><span> window.</span><span>location</span><span>.</span><span>host</span><span>;</span></div>
<div>
"font-family: &apos;Lucida Console&apos;; font-size: 8pt;"><span>var</span><span> currentLocation </span><span>= </span><span>currentProtocol </span><span>+</span><span> </span><span>"//"</span><span> </span><span>+</span><span> currentHostandPort</span><span>;</span></div>

<spanCalibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">
</span>

<spanCalibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">The code below shows the modification made to the upload message.</span><span><o:p></o:p></span>

<spanCalibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">
</span>

<span>// Send and upload message to the webworker</span>

"background-color: #ffff99; font-family: &apos;Lucida Console&apos;; font-size: 8pt;"><span>case</span><span> </span><span>&apos;upload&apos;</span><span>:</span>

<span>// </span><span>Check to see if backend supports parallel uploads</span>

var paralleluploads =false; 
if ($('#select_parallelupload').prop('checked')) { 
        paralleluploads = true; 

 
uploadworkers[data.id].postMessage({ 'chunk': data.blob, 'filename':data.filename, 
'directory': $("#select_directory").val(), 'chunkCount':data.chunkCount, 
'asyncstate':data.asyncstate,'paralleluploads':paralleluploads, 'currentlocation': 
currentLocation, 'id': data.id }); 
break;

最后修改了 CelerFT 接口来支持并行上传.

2015623104005997.png (628×344)

带有并行上传的CelerFT

这个项目的代码可以再我的 github 资源库上找到

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjxwgz.html