Giter Site home page Giter Site logo

delivery.js's People

Contributors

akondas avatar c272 avatar fjdelarubia avatar giantalbi avatar liamks avatar marcbachmann avatar troyth avatar zectbynmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delivery.js's Issues

Server to Client File Transfer not working. No errors

I have had the Client(chrome) to Server file transfering working for a while and recently needed to transfer files back to the Client.

I set up the file.load, send.start, and send.success event handlers and then call delivery.send(data).

First send.start is dispatched and then file.load. (I would think we would need to load the file before sending it... but w/e)

That's it. Nothing else ever happens.

Inspecting the Server delivery object I see that an entry has been added to delivery.sending

Client is never contacted in any way though. (I think, as the client's delivery.receiving object never has an entry added)

Furthermore I have noticed that the Client's delivery.connected is true (as expected)
but the Server's delivery.connected is NEVER true... (even in the delivery.connect event)

Not sure if the connected var actually does anything cause the server still receives files no problem.

Help please,
Thanks,
Ryan

Sending larger files throws JS error

Uploading a larger file - (video file 300MB) throws the following error

delivery.js:66 Uncaught RangeError: Invalid string lengthdelivery.js:66
reader.onload

I'm guessing deliveryjs dosen't chunk the data?

Mime Types Still Broken. [NPM VERSION]

Upon initiating a file transfer, this error is thrown now, I believe a package you were depending on has changed.

this.mimeType = mime.lookup(this.path);
^

TypeError: mime.lookup is not a function

Server to server connection(compilation error)

var socket = io.connect('http://localhost:5001'),
^
TypeError: undefined is not a function
at Object. (C:\xampp\htdocs\iothss\git-iothss\rpi\server.js:6:17)

at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

delivery.send : mime.lookup is not a function

Hello,

I have this error :

/node_modules/delivery/lib/delivery.server.js:86
  this.mimeType = mime.lookup(this.path);
                       ^

TypeError: mime.lookup is not a function
    at FilePackage.getMimeType (/opt/A7/node_modules/delivery/lib/delivery.server.js:86:24)
    at new FilePackage (/opt/A7/node_modules/delivery/lib/delivery.server.js:58:10)
    at Delivery.send (/opt/A7/node_modules/delivery/lib/delivery.server.js:165:21)
    at /opt/A7/index.js:45:15
    at ChildProcess.exithandler (child_process.js:268:7)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

It happens when I use delivery.send on server side and it seems to be a module problem.

Can you help me please ?

Thanks !

fails for large file.

I tried uploading 120 MB file and it failed .Is there any other way around to get it done.

Can use with angular js

I want to Create web app that send file from node js to Client that use angular js
Can i use delivery to send file ??

Thank you.

Submit all form inputs

Hi, can this module be used to submit all form elements. inputs and files at the same time?
I need to send 1-3 files and some inputs values at the same time.
I was trying to emit a simple object by using readAsBinaryString and encode it to base64 and send all images along with form data ( {id: 1, file1: base64, file2: base64,otherinput: value ...} ), it works, but i am having problems with 50MB+ files so i'm after a module to do that for me.
Thanks and great job.

Max transfer size?

I'd like to use Delivery to send .zip files that are up to ~500mb in size between servers. Does Delivery have any known issues or limitations for files of this size?

Download file?

The example source code shows how to display an image that was downloaded to the client (browser) but how would I allow the user to download the (binary, not an image) file that gets sent from the server to the browser?

Missing error handler and pubSub not defined

Hi,

Thanks a lot for delivery. I've got it working and files are being send (server to server) however I get an annoying error message every time:

Missing error handler on socket.
ReferenceError: pubSub is not defined
at Socket. (/Users/thijsnieuwkoop/node_modules/delivery/lib/delivery.server.js:125:5)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Socket.onevent (/Users/thijsnieuwkoop/node_modules/socket.io/lib/socket.js:330:8)
at Socket.onpacket (/Users/thijsnieuwkoop/node_modules/socket.io/lib/socket.js:290:12)
at Client.ondecoded (/Users/thijsnieuwkoop/node_modules/socket.io/lib/client.js:193:14)
at Decoder.Emitter.emit (/Users/thijsnieuwkoop/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
at Decoder.add (/Users/thijsnieuwkoop/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
at Client.ondata (/Users/thijsnieuwkoop/node_modules/socket.io/lib/client.js:175:18)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Socket.onPacket (/Users/thijsnieuwkoop/node_modules/socket.io/node_modules/engine.io/lib/socket.js:99:14)
at emitOne (events.js:77:13)
at XHR.emit (events.js:169:7)
at XHR.Transport.onPacket (/Users/thijsnieuwkoop/node_modules/socket.io/node_modules/engine.io/lib/transport.js:91:8)
at callback (/Users/thijsnieuwkoop/node_modules/socket.io/node_modules/engine.io/lib/transports/polling.js:202:10)

What is going on?

Server side:
io.sockets.on('connection', function(socket){
var delivery = dl.listen(socket);
delivery.on('receive.success', function(file){
fs.writeFile(file.name, file.buffer, function(err2){
if (err2){
console.log('File could not be saved: '+err2);
} else {
console.log('File '+file.name+' saved')
}
});
});
});

Upload progress feature

I'd like to be able to show my client how much time is left until the upload is completed. Is there a possibility of implementing this? My scenario would be a browser to server transmission.

Bower

Please put Delivery on Bower (with the same name used on NPM), for client->server it would make dependency management simpler.
Thank you

RegEx compatibility

Just a suggestion for the browser-side client. To get maximum browser compatibility for your isImage regex, you may want to construct it with new RegExp('...here...', 'i') because the flags aren't universally supported using a regex-literal.

Extra params don't seem to be sent

So far, Delivery.js has amazed me when it comes to simplicity of sending files through Socket.io. Props for making such a module! :-)

When I use delivery.send(file,extraParams) (extraParams being an object, as described in the readme), and I check the content of file on the server after receive.succes, I don't see the property params (I used Object.keys() to retrieve all the keys from the file-object), and reading file.params returns undefined.

I'd like to send meta-data with my application. Do you have an idea how I can include this meta data (or params) after all? I tried altering Delivery.prototype.send, FilePackage and FilePackage.prototype.prepBatch; but with no avail so far. Could you give me a pointer for fixing this, or help me out here?

Thanks in advance for taking a look at it!

Server to server transfer crashes recipient node process

Hello, I'm attempting to push a .jpg file from one machine to another server-to server via delivery. I am seeing that upon receiving the image file, when I try to write the buffer to disk, the server side totally crashes. It's as if the try cach wasn't even there!

delivery.on('receive.success', function(file){
console.log('receive.success',file);
try{
console.log('attempting to write buffer to disk');
fs.writeFile(file.name, file.buffer, function(err){
*** crashes right here. reguardless of being in a try catch ***

below is my console output:

Zachrys-MacBook-Pro:whiteboard zbaker$ node server.js
info - socket.io started
debug - client authorized
info - handshake authorized a9QKkyvdNzI_W_YW4cXM
debug - setting request GET /socket.io/1/websocket/a9QKkyvdNzI_W_YW4cXM
debug - set heartbeat interval for client a9QKkyvdNzI_W_YW4cXM
debug - client authorized for
debug - websocket writing 1::
debug - client authorized for /imgPoster
debug - websocket writing 1::/imgPoster
New connection from
debug - websocket writing 5::/imgPoster:{"name":"delivery.connect","args":[""]}
debug - websocket writing 5::/imgPoster:{"name":"send.success","args":["9b93ecdd-d814-4ed9-8342-0f5d1e2eb377"]}
receive.success { name: 'macbook1-1374974760515.jpg',
pubSub: { channels: { 'receive.success': [Object], 'file.load': [Object] } },
size: undefined,
data: '/9j/4UGYRXhpZgAASUkqAAgAAAAJAA8BAgAGAAAAegAAABABAgAcAAAAgAAAABIBAwABAAAAAQAAABoBBQABAAAAoAAAABsBBQABAAAAqAAAACgBAwABAAAAAgAAADIBAgAUAAAAsAAAABMCAwABAAAAAgAAAGmHBAABAAAAxAAAAFAlAABDYW5vbgBDYW5vbiBFT1MgRElHSVRBTCBSRUJFTCBYU2kAAAAAAEgAAAABAAAASAAAAAEAAAAyMDEyOjExOjE0IDE1OjEwOjQ2AB8AmoIFAAEAAAA+AgAAnYIFAAEAAABGAgAAIogDAAEAAAAAAAAAJ4gDAAEAAACQAQAAAJAHAAQAAAAwMjIxA5ACA
{{{{{ and a whole lot more image data }}}}
055q3Hh1ztYsRxxjmvanDXnbtY8Om4KTi1of//Z',
uid: '7af23b0c-7d23-44db-a65a-8cbd88a38cb8',
buffer: <Buffer ff d8 ff e1 41 98 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 09 00 0f 01 02 00 06 00 00 00 7a 00 00 00 10 01 02 00 1c 00 00 00 80 00 00 00 12 01 03 00 01 ...> }
attempting to write buffer to disk

/Users/zbaker/SVN7/projects/whiteboard/node_modules/delivery/lib/delivery.server.js:125
pubSub.publish('receive.start',file.uid);
^
ReferenceError: pubSub is not defined
at Socket. (/Users/zbaker/SVN7/projects/whiteboard/node_modules/delivery/lib/delivery.server.js:125:5)
at Socket.EventEmitter.emit as $emit
at SocketNamespace.handlePacket (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/namespace.js:335:22)
at Manager.onClientMessage (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/manager.js:488:38)
at WebSocket.Transport.onMessage (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/transport.js:387:20)
at Parser. (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10)
at Parser.EventEmitter.emit (events.js:95:17)
at finish (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/transports/websocket/hybi-16.js:288:16)
at Parser.expectHandler (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/transports/websocket/hybi-16.js:299:15)
at Parser.add (/Users/zbaker/SVN7/projects/whiteboard/node_modules/socket.io/lib/transports/websocket/hybi-16.js:466:24)

Server to Server Seems to Send Data Twice.

I'm trying to use your library to do fast server to server file transfers. I've attempted to use your examples.

receiver.js

var io  = require('socket.io').listen(5001),
    dl  = require('delivery'),
    fs  = require('fs');

io.sockets.on('connection', function(socket){
  var delivery = dl.listen(socket);

  delivery.on('receive.success',function(file){
    fs.writeFile('./data2/' + file.name, file.buffer, function(err){
      if (err) {
        console.log('File could not be saved.', file.uid, file.name);
      } else {
        console.log('File saved.', file.uid, file.name);
      };
    });
  });
});

sender.js

var socket = require('socket.io-client')('http://0.0.0.0:5001');
var dl = require('delivery')
var fs = require('fs')
var async = require('async')

socket.on('connect', function(){
  var delivery = dl.listen(socket);
  delivery.connect()

  console.log('----connected----')

  delivery.on('delivery.connect',function(delsocket){
    console.log('delivery connected')

    delsocket.on('send.success',function(fileUID){
      console.log("file was successfully sent.", fileUID);
    });

    fs.readdir('./data1', function(err, files) {
      async.eachSeries(files, function(f, cb) {
        console.log('called', f)
        delivery.send({
          name: f,
          path: './data1/' + f
        })
        cb()
      })
    })
  });

});

It seems that the loop only does a "delivery.send" once per file, but the send.success triggers twice per file. I've tried listening on the overall delivery for send.success but also on the delivery.connect event too.

----connected----
delivery connected
called 1425339118.sst
called 1425339126.sst
called 1425339135.sst
called thisisanewfile.txt
file was successfully sent. 863defe2-be89-4d24-a1a7-bbba02b87cc6
file was successfully sent. 863defe2-be89-4d24-a1a7-bbba02b87cc6
file was successfully sent. 772296e5-5e7d-4387-a23e-298dd7dd8829
file was successfully sent. 772296e5-5e7d-4387-a23e-298dd7dd8829
file was successfully sent. d783486d-1b63-42f4-99e0-13ec47cbd8fa
file was successfully sent. d783486d-1b63-42f4-99e0-13ec47cbd8fa
file was successfully sent. e6a36bde-1eb9-4dc8-b7e1-e1f7c98ea6da
file was successfully sent. e6a36bde-1eb9-4dc8-b7e1-e1f7c98ea6da

Thanks.

socket.io gets Disconnected

Server to Server Communication issue (#20)

Receiver Node LOG

Connected to Server socket.
File 0.jpg saved
File 1.jpg saved
File 2.jpg saved
TypeError: Cannot read property 'uid' of null
    at Array.<anonymous> (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\
delivery\lib\delivery.server.js:124:42)
    at PubSub.publish (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\del
ivery\lib\delivery.server.js:27:11)
    at Socket.<anonymous> (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules
\delivery\lib\delivery.server.js:155:18)
    at Socket.emit (events.js:107:17)
    at Socket.onevent (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\soc
ket.io\lib\socket.js:335:8)
    at Socket.onpacket (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\so
cket.io\lib\socket.js:295:12)
    at Client.ondecoded (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\s
ocket.io\lib\client.js:193:14)
    at Decoder.Emitter.emit (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modul
es\socket.io\node_modules\socket.io-parser\node_modules\component-emitter\index.
js:134:20)
    at Decoder.add (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\socket
.io\node_modules\socket.io-parser\index.js:247:12)
    at Client.ondata (C:\xampp\htdocs\iothss\git-iothss\iothss\node_modules\sock
et.io\lib\client.js:175:18)
Socket Disconnected!
File 3.jpg saved

Receive Node Code

function receiveimage(delivery,dir){
    delivery.on('receive.success',function(file){
        fs.writeFile( __dirname + '/img/' + dir + '/' + file.name, file.buffer, function(err){
            if(err){
                console.log('File could not be saved: ' + err);
            }else{
                console.log('File ' + file.name + " saved");
            };
        });
    });
}

Sender Node LOG

Sending Image (1/4)...
Sending Image (2/4)...
Sending Image (3/4)...
Sending Image (4/4)...
-----------------------------------
Images Uploaded Successfully!

Sender Node Code:

function sendimage(delivery,dir){
  for(var i=0;i<4;i++) {
    console.log( "Sending Image (" + (i+1) + "/4)..." );
    delivery.send({
      name: i + '.jpg',
      path: './img/' + dir + '/' + i + '.jpg'
    });

    delivery.on('send.success',function(){
      console.log("File successfully sent!");
    });
  }
}

Modification in delivery.server.js

modified_server

I think two places (shown as a yellow pointer in the above file) are modified to transfer files from server to client. Please check it out.

TypeError: Cannot read property 'uid' of null

Using the following code to send a file from a node.js backend:

var ioClient = require('socket.io-client');
var socket = ioClient.connect('http://' + host);
socket.on('connect', function() {
    delivery = dl.listen(socket);
    delivery.connect();
    delivery.on('delivery.connect', function(delivery){
        delivery.send({
            name: file_name,
            path : file_path
        });
        delivery.on('send.success', function(file){
            // something....
        });
    });
});

To this server:

var io  = require('socket.io').listen(5001);
io.sockets.on('connection', function(socket){
  var delivery = dl.listen(socket);
  delivery.on('receive.success',function(file){
      // something...
  });
});

Results the following error:

2016-01-08T23:59:06.846533210Z Missing error handler on `socket`.
2016-01-08T23:59:06.846544375Z TypeError: Cannot read property 'uid' of null
2016-01-08T23:59:06.846547082Z     at Array. (/src/node_modules/delivery/lib/delivery.server.js:124:42)
2016-01-08T23:59:06.846549676Z     at PubSub.publish (/src/node_modules/delivery/lib/delivery.server.js:27:11)
2016-01-08T23:59:06.846551777Z     at Socket. (/src/node_modules/delivery/lib/delivery.server.js:155:18)
2016-01-08T23:59:06.846553851Z     at emitOne (events.js:77:13)
2016-01-08T23:59:06.846555769Z     at Socket.emit (events.js:169:7)
2016-01-08T23:59:06.846557679Z     at Socket.onevent (/src/node_modules/socket.io/lib/socket.js:335:8)
2016-01-08T23:59:06.846559655Z     at Socket.onpacket (/src/node_modules/socket.io/lib/socket.js:295:12)
2016-01-08T23:59:06.846561625Z     at Client.ondecoded (/src/node_modules/socket.io/lib/client.js:193:14)
2016-01-08T23:59:06.846564037Z     at Decoder.Emitter.emit (/src/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
2016-01-08T23:59:06.846566300Z     at Decoder.add (/src/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)

The file json data is the following received on the server side:

{"name":"filename.txt","pubSub":{"channels":{"receive.success":[null,null],"file.load":[null]}},"data":"
...... FILE_DATA_HERE.......
]}}

Is there anything I am missing here?

Tracking progress

Hey.

Is it possible to track the upload progress so I can report it back to my client as a progress bar? My scenario is sending from a browser to the server.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.