Open RNCTX opened 4 years ago
Hi. This Plugin is wonderful. I'm finding the same problem, how to pass a variable in the file name? I tried all possible msg.payload / payload / topic / etc but no luck. Waiting for an answer.
thanks in advance!
Also noted: if I pass an incremental fariable in the msg.payload, and then set the name of the imag as msg.payload Node-RED crashes.
If it's of any help.
As an update to this, I ran into trouble with Xvfb and/or electron trying to get at my NAS's bluetooth device, which would cause a crash due to Dbus blocking access to the bluetooth device (already in use, I have X running on the NAS too so I can use graphical apps over VNC).
Sometimes I could "clean up" the running processes and sometimes not based on these errors.
Due to all of the above I switched to using node-puppeteer via a function. Headless Chrome or Firefox via puppeteer does not require an X session, so is a much cleaner process chain.
See example here:
https://github.com/pokiiio/node-red-contrib-web-page-screenshot/issues/4#issuecomment-612041704
To answer the question about variable names, the answer there is to declare a flow variable from your original object in a change node before you change any other object properties. The flow variable will then be accessible from anywhere in the flow for naming your screenshot and giving it a file path.
You can use a Jsonata expression in the change node for this, something like...
"/var/www/nodered/" & $.payload.my_filename_field & ".jpg"
Since & is a string operator to concatenate strings in Jsonata, your output should be a string.
Hey, thanks for the plugin!
I'm using it with xvfb headless to parse social media posts based on a few filters, and I want to use your plugin to save a screenshot of each post that matches so that they'll be retained in case they're ever deleted by in the future by the author.
Problem is it seems that I can only specify a string without any variables for the filename. Is there a way to get a variable from the msg object for file naming? That way I could do something like msg.twitter_post_id.png and not get my screenshots crossed if more than one fires at the same time.
If I try to save the screenshot as a type msg rather than type string with a message object variable as the name I get an access denied in the console, so I hope it's just a matter of defining a path and file extension somehow?