Bidirectional File Transfers For Node.js via Socket.IO - temporary publish, waiting on pull request
Sending files to the server, and pushing files to the client should be as easy as possible. Delivery.js uses Node.js and Socket.IO to make it easy to push files to the client, or send them to the server. Files can be pushed to the client as text (utf8) or base64 (for images and binary files).
npm install delivery -g
delivery.js can be found within lib/client.
var io =dl =fs = ;iosockets;
var io =dl = ;iosockets;
dl = ;
var delivery = dl;
delivery.connect is called when a client connects to the server.
receive.start is called when the server starts receiving a file. The callback function takes a filePackage object that describes the file being sent.
receive.success is called once the file has been successfully reveived by the server. The callback function takes a filePackage.
file.load is called after .send() is called and immediately after the file is loaded. The callback function takes a filePackage.
send.start is called after .send() is called and immediately after the file begins being sent to the client. The callback function takes a filePackage.
send.success is called after .send() is called and once confirmation is received form the client that the the file sent was successfully received. The callback function takes the uid of the file that was sent.
FilePackage objects encapsulate files and includes a text representation (utf8), or base64 representation of the file. They also include the file's meta data, including
returns true if the file has a corresponding mime type that is an image. It is possible that this method could return false if your file is an image, but does not have a mimetype, or does not have a mimetype of image/gif, image/jpeg, image/png, image/svg+xml, image/tiff. Look for
var imageFilter within delivery.js if you'd like to add additional mimetypes.
returns true if the server used
returns the text representation of the file sent. If the file has been base64 encoded it returns the base64 encoded version of the file.
returns the base64 representation of the file prefixed with the data and mimetype necessary to display an image within
Client events mirror those on the server, see server events above for more details.
Delivery.js is released under the MIT license: