Can you use DDP to upload files?

I am working on an IOT device that is sending small sound files (less then 500KB) every 10 seconds to my Meteor app which is then processing the file and sending a response back to the device. Once the response has been sent the file will be deleted from the server.

I have written the program on the IOT device in python and am using to communicate with Meteor via DDP. My problem is I can’t for the life of me figure out how to get a file from my IOT device to my Meteor app via DDP. I could upload the file to a folder on the server via FTP and reference it in Meteor, but that feels sloppy and extremely insecure. Any thoughts on the best way to accomplish the file upload would be much appreciated!

DDP could sent data in EJSON format. So you should just convert your file into JSON-able type and send via DDP. You can encode the file as base64 string and dencode then on the server side. For better performance you may create a custom EJSON type for binary data or just use binary options for EJSON - see the docs

Take a look at these for inspiration:

File transfer over DDP is quite inefficient. CollectionFS originally used DDP but switched to HTTP as it was much faster.

1 Like

Regarding this, did CollectionFS use the binary options for EJSON that @mrzafod mentioned above? Or compression of chunks? I’m pondering these mechanisms as well and am curious about what they found.

Yes, pure binary data upload via DDP available in Meteor-Files package