Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

socketio-file-upload

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socketio-file-upload - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

18

client.js

@@ -132,3 +132,3 @@ /*

content: content,
base64: self.serializedOctets ? false : true
base64: !self.serializedOctets
});

@@ -150,2 +150,18 @@ transmitPos = event.loaded;

// Listen for an "error" event. Stop the transmission if one is received.
reader.addEventListener("error", function(){
socket.emit("siofu_done", {
id: id,
interrupt: true
});
});
// Do the same for the "abort" event.
reader.addEventListener("abort", function(){
socket.emit("siofu_done", {
id: id,
interrupt: true
});
});
// Transmit the "start" message to the server.

@@ -152,0 +168,0 @@ socket.emit("siofu_start", {

12

client.min.js

@@ -7,7 +7,7 @@ /* Socket IO File Upload Client-Side Library

window.SocketIOFileUpload=function(m){var h=this;if(!window.File||!window.FileReader)throw Error("Socket.IO File Upload: Browser Not Supported");var f={},n=[],p=[];h.fileInputElementId="siofu_input";h.useText=!1;h.serializedOctets=!1;var k=function(a,b){var c=document.createEvent("Event");c.initEvent(a,!1,!1);for(var j in b)b.hasOwnProperty(j)&&(c[j]=b[j]);return h.dispatchEvent(c)},q=function(a){if(k("start",{file:a})){var b=new FileReader,c=0,j=n.length,f=h.useText,d;n.push(a);b.addEventListener("progress",
function(a){if(!(a.loaded<a.total)){var d;if(f)d=b.result.slice(c,a.loaded);else try{var l=new Uint8Array(b.result,c,a.loaded);if(h.serializedOctets)d=l;else{var g,k=l.buffer.byteLength,e="";for(g=0;g<k;g+=3)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[l[g]>>2],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(l[g]&3)<<4|l[g+1]>>4],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(l[g+1]&15)<<2|l[g+2]>>6],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[l[g+
2]&63];2===k%3?e=e.substring(0,e.length-1)+"=":1===k%3&&(e=e.substring(0,e.length-2)+"==");d=e}}catch(n){m.emit("siofu_done",{id:j,interrupt:!0});return}m.emit("siofu_progress",{id:j,start:c,end:a.loaded,content:d,base64:h.serializedOctets?!1:!0});c=a.loaded}});b.addEventListener("load",function(){m.emit("siofu_done",{id:j});k("load",{file:a,reader:b,name:d})});m.emit("siofu_start",{name:a.name,mtime:a.lastModifiedDate,encoding:f?"text":"octet",id:j});p.push(f?function(c){b.readAsText(a);d=c}:function(c){b.readAsArrayBuffer(a);
d=c})}},d=function(a){var b=a.target.files||a.dataTransfer.files;a.preventDefault();if(0<b.length&&k("choose",{files:b}))for(a=0;a<b.length;a++)q(b[a])};this.listenOnInput=function(a){a.files&&a.addEventListener("change",d,!1)};this.listenOnDrop=function(a){a.addEventListener("dragover",function(a){a.preventDefault()},!1);a.addEventListener("drop",d)};this.prompt=function(){var a;a=document.getElementById(h.fileInputElementId);a||(a=document.createElement("input"),a.setAttribute("type","file"),a.setAttribute("id",
h.fileInputElementId),a.style.display="none",document.body.appendChild(a));a.addEventListener("change",d,!1);var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null);a.dispatchEvent(b)};this.addEventListener=function(a,b){f[a]||(f[a]=[]);f[a].push(b)};this.removeEventListener=function(a,b){if(!f[a])return!1;for(var c=0;c<f[a].length;c++)if(f[a][c]===b)return f[a].splice(c,1),!0;return!1};this.dispatchEvent=function(a){var b=f[a.type];if(!b)return!0;
for(var c=!0,d=0;d<b.length;d++)!1===b[d](a)&&(c=!1);return c};m.on("siofu_ready",function(a){p[a.id](a.name)});m.on("siofu_complete",function(a){k("complete",{file:n[a.id],success:a.success})})};
window.SocketIOFileUpload=function(k){var j=this;if(!window.File||!window.FileReader)throw Error("Socket.IO File Upload: Browser Not Supported");var f={},n=[],p=[];j.fileInputElementId="siofu_input";j.useText=!1;j.serializedOctets=!1;var l=function(a,b){var c=document.createEvent("Event");c.initEvent(a,!1,!1);for(var e in b)b.hasOwnProperty(e)&&(c[e]=b[e]);return j.dispatchEvent(c)},q=function(a){if(l("start",{file:a})){var b=new FileReader,c=0,e=n.length,f=j.useText,g;n.push(a);b.addEventListener("progress",
function(a){if(!(a.loaded<a.total)){var g;if(f)g=b.result.slice(c,a.loaded);else try{var m=new Uint8Array(b.result,c,a.loaded);if(j.serializedOctets)g=m;else{var h,l=m.buffer.byteLength,d="";for(h=0;h<l;h+=3)d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[m[h]>>2],d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(m[h]&3)<<4|m[h+1]>>4],d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(m[h+1]&15)<<2|m[h+2]>>6],d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[m[h+
2]&63];2===l%3?d=d.substring(0,d.length-1)+"=":1===l%3&&(d=d.substring(0,d.length-2)+"==");g=d}}catch(n){k.emit("siofu_done",{id:e,interrupt:!0});return}k.emit("siofu_progress",{id:e,start:c,end:a.loaded,content:g,base64:!j.serializedOctets});c=a.loaded}});b.addEventListener("load",function(){k.emit("siofu_done",{id:e});l("load",{file:a,reader:b,name:g})});b.addEventListener("error",function(){k.emit("siofu_done",{id:e,interrupt:!0})});b.addEventListener("abort",function(){k.emit("siofu_done",{id:e,
interrupt:!0})});k.emit("siofu_start",{name:a.name,mtime:a.lastModifiedDate,encoding:f?"text":"octet",id:e});p.push(f?function(c){b.readAsText(a);g=c}:function(c){b.readAsArrayBuffer(a);g=c})}},g=function(a){var b=a.target.files||a.dataTransfer.files;a.preventDefault();if(0<b.length&&l("choose",{files:b}))for(a=0;a<b.length;a++)q(b[a])};this.listenOnInput=function(a){a.files&&a.addEventListener("change",g,!1)};this.listenOnDrop=function(a){a.addEventListener("dragover",function(a){a.preventDefault()},
!1);a.addEventListener("drop",g)};this.prompt=function(){var a;a=document.getElementById(j.fileInputElementId);a||(a=document.createElement("input"),a.setAttribute("type","file"),a.setAttribute("id",j.fileInputElementId),a.style.display="none",document.body.appendChild(a));a.addEventListener("change",g,!1);var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null);a.dispatchEvent(b)};this.addEventListener=function(a,b){f[a]||(f[a]=[]);f[a].push(b)};
this.removeEventListener=function(a,b){if(!f[a])return!1;for(var c=0;c<f[a].length;c++)if(f[a][c]===b)return f[a].splice(c,1),!0;return!1};this.dispatchEvent=function(a){var b=f[a.type];if(!b)return!0;for(var c=!0,e=0;e<b.length;e++)!1===b[e](a)&&(c=!1);return c};k.on("siofu_ready",function(a){p[a.id](a.name)});k.on("siofu_complete",function(a){l("complete",{file:n[a.id],success:a.success})})};
{
"name": "socketio-file-upload",
"version": "0.2.2",
"version": "0.2.3",
"description": "Uploads files to a Node.JS server using Socket.IO",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc