PASTIN: Upload & share files

Hello there,

In case anyone is interested, we've just published a file upload & share service at rapidAPI to be used from NR.
It was created to our convenience, but we have been asked to share it.
There's a file p2p network behing and some file ups&downs but the outcome is extremely simple.

You inject a file on one end and you receive a URL to the uploaded file on the other end. Simple
We did dis originally to complement the whatsapp messaging service (WHIN).

Both work together quite nicely but they're not necessary linked. One can use PASTIN just to upload a file from NR to 'the cloud' and get a link that can be used elsewhere from anyone.

In combination with WHIN it is more powerful. An example is a camera that feeds a image alert on detected motion and this image is sent to your whatsapp through WHIN... sky is the linit!

Here's some flow example. Find PASTIN on rapidApi.com to get your free key.

PD: If you're not interested on the whatsapp piece, just ignore the WHIN missing node error and delete that part of the flow.

[{"id":"3479553faa034cef","type":"tab","label":"Pastin & WHIN","disabled":false,"info":"","env":[]},{"id":"30539631bc56ce88","type":"function","z":"3479553faa034cef","name":"upload","func":"const apikey =\"\";  // Enter your key inside the quotes.\nmsg.method= \"POST\";\nmsg.url = \"https://whin-dev.p.rapidapi.com/upload\";\nmsg.headers = {\n        \"content-type\": \"application/octet-stream\",\n        \"X-RapidAPI-Key\": apikey,\n        \"X-RapidAPI-Host\": \"pastin1.p.rapidapi.com\" \n}\nmsg.payload = Buffer.from(\"pastin,\"+msg.payload.toString('base64'));\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1110,"y":220,"wires":[["935e1713cd536e3f"]]},{"id":"935e1713cd536e3f","type":"http request","z":"3479553faa034cef","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":1250,"y":220,"wires":[["6f4a237c27a75506"]]},{"id":"febb1655bbdc9f29","type":"comment","z":"3479553faa034cef","name":"Downloading Samples","info":"","x":180,"y":80,"wires":[]},{"id":"c14d41e9e3b99748","type":"inject","z":"3479553faa034cef","name":"Audio","props":[{"p":"url","v":"https://filesamples.com/samples/audio/mp3/sample3.mp3","vt":"str"},{"p":"filename","v":"/data/audio.mp3","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":140,"wires":[["eeb47b719a78ae36"]]},{"id":"eeb47b719a78ae36","type":"http request","z":"3479553faa034cef","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":390,"y":220,"wires":[["f2d43b08bb30f369"]]},{"id":"947a9852ef867158","type":"inject","z":"3479553faa034cef","name":"PDF","props":[{"p":"url","v":"https://filesamples.com/samples/document/pdf/sample1.pdf","vt":"str"},{"p":"filename","v":"/data/pdf.pdf","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":180,"wires":[["eeb47b719a78ae36"]]},{"id":"8dfb915e14af2263","type":"inject","z":"3479553faa034cef","name":"Video","props":[{"p":"url","v":"https://filesamples.com/samples/video/mp4/sample_960x540.mp4","vt":"str"},{"p":"filename","v":"/data/video.mp4","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":220,"wires":[["eeb47b719a78ae36"]]},{"id":"e5e73ca34c647360","type":"inject","z":"3479553faa034cef","name":"Pic/Jpeg","props":[{"p":"url","v":"https://filesamples.com/samples/image/jpg/sample_1920%C3%971280.jpg","vt":"str"},{"p":"filename","v":"/data/pic.jpg","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":260,"wires":[["eeb47b719a78ae36"]]},{"id":"c7a8061b649c0282","type":"inject","z":"3479553faa034cef","name":"Pic/png","props":[{"p":"url","v":"https://filesamples.com/samples/image/png/sample_640%C3%97426.png","vt":"str"},{"p":"filename","v":"/data/pic.png","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":300,"wires":[["eeb47b719a78ae36"]]},{"id":"f2d43b08bb30f369","type":"file","z":"3479553faa034cef","name":"","filename":"filename","filenameType":"msg","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":560,"y":220,"wires":[[]]},{"id":"a27e04f8d14093f3","type":"comment","z":"3479553faa034cef","name":"Uploading Samples","info":"","x":790,"y":80,"wires":[]},{"id":"ed57b0a3d75d65e6","type":"inject","z":"3479553faa034cef","name":"Audio","props":[{"p":"url","v":"https://filesamples.com/samples/audio/mp3/sample3.mp3","vt":"str"},{"p":"filename","v":"/data/audio.mp3","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":770,"y":140,"wires":[["920f9612ef4dab17"]]},{"id":"128fc9b4a48d168d","type":"inject","z":"3479553faa034cef","name":"PDF","props":[{"p":"url","v":"https://filesamples.com/samples/document/pdf/sample1.pdf","vt":"str"},{"p":"filename","v":"/data/pdf.pdf","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":770,"y":180,"wires":[["920f9612ef4dab17"]]},{"id":"0c91d09ed9421e7d","type":"inject","z":"3479553faa034cef","name":"Video","props":[{"p":"url","v":"https://filesamples.com/samples/video/mp4/sample_960x540.mp4","vt":"str"},{"p":"filename","v":"/data/video.mp4","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":770,"y":220,"wires":[["920f9612ef4dab17"]]},{"id":"2a6ed8a6a0626c90","type":"inject","z":"3479553faa034cef","name":"Pic/Jpeg","props":[{"p":"url","v":"https://filesamples.com/samples/image/jpg/sample_1920%C3%971280.jpg","vt":"str"},{"p":"filename","v":"/data/pic.jpg","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":780,"y":260,"wires":[["920f9612ef4dab17"]]},{"id":"db498c021d6443a7","type":"inject","z":"3479553faa034cef","name":"Pic/png","props":[{"p":"url","v":"https://filesamples.com/samples/image/png/sample_640%C3%97426.png","vt":"str"},{"p":"filename","v":"/data/pic.png","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":770,"y":300,"wires":[["920f9612ef4dab17"]]},{"id":"920f9612ef4dab17","type":"file in","z":"3479553faa034cef","name":"","filename":"filename","filenameType":"msg","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":960,"y":220,"wires":[["30539631bc56ce88"]]},{"id":"6f4a237c27a75506","type":"debug","z":"3479553faa034cef","name":"URLout","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1420,"y":220,"wires":[]},{"id":"df50c4e4248bf4dc","type":"comment","z":"3479553faa034cef","name":"Replace apiKey","info":"","x":1100,"y":180,"wires":[]},{"id":"defdb364f54ac3f4","type":"comment","z":"3479553faa034cef","name":"Sending files using WHIN","info":"","x":210,"y":480,"wires":[]},{"id":"6b60fde9b8f2190f","type":"inject","z":"3479553faa034cef","name":"Audio","props":[{"p":"filename","v":"/data/audio.mp3","vt":"str"},{"p":"type","v":"audio","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":540,"wires":[["f4f1c7612f5b634f"]]},{"id":"5f0085ac0e580512","type":"inject","z":"3479553faa034cef","name":"PDF","props":[{"p":"filename","v":"/data/pdf.pdf","vt":"str"},{"p":"type","v":"document","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":580,"wires":[["f4f1c7612f5b634f"]]},{"id":"6517d12e13a38cfc","type":"inject","z":"3479553faa034cef","name":"Video","props":[{"p":"filename","v":"/data/video.mp4","vt":"str"},{"p":"type","v":"video","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":620,"wires":[["f4f1c7612f5b634f"]]},{"id":"aea77d90c38af627","type":"inject","z":"3479553faa034cef","name":"Pic/Jpeg","props":[{"p":"filename","v":"/data/pic.jpg","vt":"str"},{"p":"type","v":"image","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":660,"wires":[["f4f1c7612f5b634f"]]},{"id":"2e5dbcc3ce21d3b8","type":"inject","z":"3479553faa034cef","name":"Pic/png","props":[{"p":"filename","v":"/data/pic.png","vt":"str"},{"p":"type","v":"image","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":700,"wires":[["f4f1c7612f5b634f"]]},{"id":"f4f1c7612f5b634f","type":"file in","z":"3479553faa034cef","name":"","filename":"filename","filenameType":"msg","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":380,"y":620,"wires":[["6047cb6bf04f787f"]]},{"id":"f94417b6397b6ced","type":"whin-send","z":"3479553faa034cef","name":"","auth":"3ba0d45d907df051","x":1070,"y":620,"wires":[["333351d92fade0af"]]},{"id":"6047cb6bf04f787f","type":"function","z":"3479553faa034cef","name":"upload","func":"msg.method= \"POST\";\nmsg.url = \"https://whin-dev.p.rapidapi.com/upload\";\nmsg.headers = {\n        \"content-type\": \"application/octet-stream\",\n        \"X-RapidAPI-Key\": \"92d3cb0ef9msh37e4effedbee3f5p1081bejsn857a6a5877ef\",\n        \"X-RapidAPI-Host\": \"pastin1.p.rapidapi.com\" \n}\nmsg.payload = Buffer.from(\"pastin,\"+msg.payload.toString('base64'));\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":620,"wires":[["8f77b88d286078a6"]]},{"id":"8f77b88d286078a6","type":"http request","z":"3479553faa034cef","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":690,"y":620,"wires":[["3afe2e33fa4c65de"]]},{"id":"507f99ad795bf516","type":"comment","z":"3479553faa034cef","name":"Replace apiKey","info":"","x":520,"y":580,"wires":[]},{"id":"3afe2e33fa4c65de","type":"function","z":"3479553faa034cef","name":"PrepareMessage","func":"var message={}\nmessage[msg.type]={'url':msg.payload}\nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":620,"wires":[["f94417b6397b6ced"]]},{"id":"a16466e6fb165a93","type":"comment","z":"3479553faa034cef","name":"Configure WHIN node","info":"","x":1060,"y":580,"wires":[]},{"id":"333351d92fade0af","type":"debug","z":"3479553faa034cef","name":"debug 75","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1240,"y":620,"wires":[]},{"id":"3ba0d45d907df051","type":"whin-config","name":"alsak0de","apikey":""}]