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.6.2 to 0.6.3

39

client.js

@@ -29,2 +29,5 @@ /*

// Do not check function indentation because this is intentionally ignored in order to preserve history in git.
/* eslint-disable indent */
/**

@@ -37,6 +40,7 @@ * A client-side JavaScript object to handle file uploads to a Node.JS server

(function (scope, name, factory) {
/* eslint-disable no-undef */
if (typeof define === "function" && define.amd) {
define([], factory);
}
else if (typeof module === 'object' && module.exports) {
else if (typeof module === "object" && module.exports) {
module.exports = factory();

@@ -47,2 +51,3 @@ }

}
/* eslint-enable no-undef */
}(this, "SocketIOFileUpload", function () {

@@ -59,8 +64,8 @@ return function (socket) {

if ( !window.siofu_global ) {
window.siofu_global = {
instances: 0,
downloads: 0
}
}
if ( !window.siofu_global ) {
window.siofu_global = {
instances: 0,
downloads: 0
};
}

@@ -74,3 +79,3 @@ // Private and Public Variables

self.fileInputElementId = "siofu_input_"+siofu_global.instances++;
self.fileInputElementId = "siofu_input_"+window.siofu_global.instances++;
self.resetFileInputs = true;

@@ -117,3 +122,3 @@ self.useText = false;

_stopListeningTo.apply(this, _listenedReferences[i]);
};
}
_listenedReferences = [];

@@ -147,3 +152,3 @@ };

var reader = new FileReader(),
id = siofu_global.downloads++,
id = window.siofu_global.downloads++,
uploadComplete = false,

@@ -200,3 +205,3 @@ useText = self.useText,

});
}
};

@@ -208,3 +213,3 @@ // Callback when tranmission is complete.

});
}
};

@@ -230,3 +235,3 @@ // Load a "chunk" of the file from offset to offset+chunkSize.

}
}
};

@@ -384,4 +389,6 @@ // Callback for when the reader has completed a load event.

try {
event.target.value = ""; //for IE11, latest Chrome/Firefox/Opera...
} catch(err) {}
event.target.value = ""; //for IE11, latest Chrome/Firefox/Opera...
} catch(err) {
// ignore
}
if (event.target.value) { //for IE5 ~ IE10

@@ -621,3 +628,3 @@ var form = document.createElement("form"),

});
}
};
}));
{
"name": "socketio-file-upload",
"version": "0.6.2",
"version": "0.6.3",
"description": "Uploads files to a Node.JS server using Socket.IO",

@@ -18,5 +18,7 @@ "keywords": [

"ecstatic": "^2.0.0",
"eslint": "^5.6.1",
"phantom": "^6.0.3",
"socket.io": "^2.1.1",
"socket.io-client": "^2.1.1",
"tape": "^4.2.0"
"tape": "^4.9.0"
},

@@ -32,2 +34,3 @@ "files": [

"scripts": {
"lint": "eslint .",
"pretest": "browserify test/serve/browser-file-transfer.js -o test/serve/bundle.js",

@@ -34,0 +37,0 @@ "test": "tape test/*.js"

@@ -12,2 +12,7 @@ Socket.IO File Upload

[![Build Status](https://travis-ci.org/sffc/socketio-file-upload.svg?branch=master)](https://travis-ci.org/sffc/socketio-file-upload)
[![Known Vulnerabilities](https://snyk.io/test/github/sffc/socketio-file-upload/badge.svg)](https://snyk.io/test/github/sffc/socketio-file-upload)
[![npm version](http://img.shields.io/npm/v/socketio-file-upload.svg?style=flat)](https://npmjs.org/package/socketio-file-upload "View this project on npm")
## Quick Start

@@ -14,0 +19,0 @@

@@ -29,2 +29,4 @@ /*

/* eslint-env node */
// Require Libraries

@@ -145,3 +147,3 @@ var util = require("util"),

var filesafeName = fileInfo.name
.replace(/[\/\?<>\\:\*\|":]|[\x00-\x1f\x80-\x9f]|^\.+$/g, "_");
.replace(/[\/\?<>\\:\*\|":]|[\x00-\x1f\x80-\x9f]|^\.+$/g, "_"); // eslint-disable-line no-control-regex, no-useless-escape

@@ -193,4 +195,5 @@ var ext = path.extname(filesafeName);

_emitComplete(socket, data.id, fileInfo.success);
console.log("SocketIOFileUploadServer Error (_uploadDone fs.utimes):");
console.log(err);
// TODO: We should probably propagate the error out to the user here.
console.log("SocketIOFileUploadServer Error (_uploadDone fs.utimes):"); // eslint-disable-line no-console
console.log(err); // eslint-disable-line no-console
_cleanupFile(data.id);

@@ -200,8 +203,12 @@ return;

_emitComplete(socket, data.id, fileInfo.success);
_cleanupFile(data.id);
// Emit the "saved" event to the server-side listeners
// The order here matters:
// _cleanupFile1 needs to be before server-side "saved" event such that the "saved" event can move the file (see #62)
// The server-side "saved" event needs to be before _emitComplete so that clientDetail can be edited (see #82)
// _emitComplete needs to happen before _cleanupFile2 so that the file info object is still valid
_cleanupFile1(data.id);
self.emit("saved", {
file: fileInfo
});
_emitComplete(socket, data.id, fileInfo.success);
_cleanupFile2(data.id);
});

@@ -215,4 +222,5 @@ }

catch (err) {
console.log("SocketIOFileUploadServer Error (_uploadDone):");
console.log(err);
// TODO: We should probably propagate the error out to the user here.
console.log("SocketIOFileUploadServer Error (_uploadDone):"); // eslint-disable-line no-console
console.log(err); // eslint-disable-line no-console
}

@@ -249,3 +257,3 @@

if (self.maxFileSize !== null
&& fileInfo.bytesLoaded > self.maxFileSize) {
&& fileInfo.bytesLoaded > self.maxFileSize) {
fileInfo.success = false;

@@ -282,4 +290,5 @@ socket.emit("siofu_error", {

catch (err) {
console.log("SocketIOFileUploadServer Error (_uploadProgress):");
console.log(err);
// TODO: We should probably propagate the error out to the user here.
console.log("SocketIOFileUploadServer Error (_uploadProgress):"); // eslint-disable-line no-console
console.log(err); // eslint-disable-line no-console
}

@@ -339,2 +348,4 @@ };

// The indentation got messed up here, but changing it would make git history less useful.
/* eslint-disable indent */
var _serverReady = function(socket, data, fileInfo){

@@ -407,2 +418,3 @@ // Find a filename and get the handler. Then tell the client that

};
/* eslint-enable indent */

@@ -415,4 +427,15 @@ var _cleanupFile = function (id) {

delete files[id];
}
};
// _cleanupFile1() followed by _cleanupFile2() is equivalent to _cleanupFile()
var _cleanupFile1 = function (id) {
var fileInfo = files[id];
if (fileInfo.writeStream) {
fileInfo.writeStream.end();
}
};
var _cleanupFile2 = function (id) {
delete files[id];
};
/**

@@ -423,3 +446,3 @@ * Private function to handle a client disconnect event.

*/
var _onDisconnect = function (socket) {
var _onDisconnect = function (socket) { // eslint-disable-line no-unused-vars
return function () {

@@ -438,4 +461,4 @@ for (var id in files) {

}
}
}
};
};

@@ -480,3 +503,3 @@ /**

_cleanupFile(id);
}
};
}

@@ -483,0 +506,0 @@ util.inherits(SocketIOFileUploadServer, EventEmitter);

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