Downloading pdf file from internet

Maybe anyone can help me with this problem.
I am trying to download a pdf file from a web address and store it on RPI. THis file is not secured, I think. I can normally download it my self from the web. But If I download the file, it seems it is empty.
I am confused. Here is the flow.

[{"id":"85a8308c80750364","type":"http request","z":"70e5f74f5e9b1992","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.lampiris.be/sites/default/files/pricesgrids/current/tarif_tip_elec_fla_nl_-_resi.pdf","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":520,"y":1540,"wires":[["eecd1c36ce19a5da"]]},{"id":"f7f56ac39d0a067e","type":"inject","z":"70e5f74f5e9b1992","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":1540,"wires":[["85a8308c80750364"]]},{"id":"f37ad39bdf1d2694","type":"debug","z":"70e5f74f5e9b1992","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":1480,"wires":[]},{"id":"3c3e0504195ec439","type":"file","z":"70e5f74f5e9b1992","name":"Lampiris file","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","x":870,"y":1540,"wires":[[]]},{"id":"eecd1c36ce19a5da","type":"function","z":"70e5f74f5e9b1992","name":"","func":"let folder = global.get('file.lampiris_folder');\nlet file = \"Lampiris_tarif_\" + Date().toString() + \".pdf\";\n\nmsg.filename = folder + file;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":1540,"wires":[["3c3e0504195ec439","f37ad39bdf1d2694"]]}]

Check the output of the function node, particularly the filename. I think you might want
(new Date()).toString()
I don't know whether UTF8 string is the correct output format for the html node. It might be better as a binary buffer.

@Colin As always, you're right. Thanks very much for the help again !!!

If only that were true.

Did you have to change it to a buffer?

Yes, indeed, @Colin , it is working perfectly now. As you might have seen, I needed that file to get elctricity tarifs from my distributor so I can update costprice in order to calculate energy costs. That's working now. Thanks!!!

greetings.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.