1
2
3
4
5
6
| /*
| formdatabuilder.js (c) 2015 KNOWLEDGECODE | MIT
| */
| (function(c){var e=function(){this.boundary="----WebKitFormBoundary"+Math.random().toString(36).slice(2);this.type="multipart/form-data; boundary="+this.boundary;this.crlf="\r\n";this.pairs=[]};e.prototype.append=function(b,a){var c=Object.prototype.toString.call(a),f=function(a){return a.replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22")},d={disposition:'form-data; name="'+f(b||"")+'"'};b&&("[object File]"===c||"[object Blob]"===c?(d.disposition+='; filename="'+f(a.name||"blob")+'"',d.type=
| a.type||"application/octet-stream",d.value=a):d.value=String(a),this.pairs.push(d))};e.prototype.getBlob=function(){var b=[],a,e=this.pairs.length;for(a=0;a<e;a++)b.push("--"+this.boundary+this.crlf+"Content-Disposition: "+this.pairs[a].disposition),this.pairs[a].type&&b.push(this.crlf+"Content-Type: "+this.pairs[a].type),b.push(this.crlf+this.crlf),b.push(this.pairs[a].value),b.push(this.crlf);b.push("--"+this.boundary+"--"+this.crlf);return c.Blob?new Blob(b):(new c.FileReaderSync).readAsArrayBuffer(function(a){var b=
| new (c.BlobBuilder||c.WebKitBlobBuilder||c.MSBlobBuilder);(a||[]).forEach(function(a){b.append(a)});return b.getBlob()}(b))};c.FormDataBuilder=e})(this);
|
|