Unable to use puppeteer in a nodejs app on cpanel? - node.js

I am using puppeteer in my nodejs application to convert html file into pdf. This is working fine in my local server and pdf is getting generated. But this is not working in cPanel. I am getting error similar to this. I tried everything mentioned on that but nothing works.
I tried setting the executable path of chrome in puppeteer in cpanel but in vain. Errpr =>
Failed to launch the browser process!
/home/xxx/public_html/xxx/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory
I tried different packages like html-pdf and node-pdf-generator. But the problem is I have designed some ejs templates according to chrome and then I am generating html files from these ejs templates. After that I am saving the pdf file in buffer and uploading this buffer to google bucket.
Flow: ejs templates -> html file -> pdf buffer -> stream buffer to gc
bucket
In other packages I am facing these issues:
Either the template is not coming as expected
Or The package has no option of storing generated pdf file in buffer.
Any solution or a different library?

Related

MacOS - Open local html file using Node js

I need to open a html file in browser using nodejs. I am trying to use "child_process". It does not seem to work. I do not want run a server/localhost to render. This is very simple html that needs to open.
import * as cpm from "child_process";
cpm.exec(`open somefilename.html`);

How to automate file upload on browserstack using nightwatch node js

I am writing automation using Nightwatch node js. I have a test for uploading a file in my application and testing it locally works perfectly. However, when I test it using BrowserStack, BrowserStack cannot access the file in my local machine.
I have also tried setting FileDetector but it gives error saying setFileDetector is not a function on browser object.
I know this function is available for selenium driver object but I am javascript browser object for writing test scripts.
browser.setFileDetector(new remote.FileDetector());
I see that you want to perform the File Upload Operation for a file available on your local machine. You can review the link: https://www.browserstack.com/automate/node#enhancements-uploads-downloads for more details.

Downloading file from Dropbox API for use in Python Environment with Apache Tika on Heroku

I'm trying to use Dropbox as a cloud-based file receptacle for an app/script. The script, written in Python, needs to take PDFs from the Dropbox and use the tika-python wrapper to convert to string.
I'm able to connect to the Dropbox API and use the files_download_to_file() method to download the PDFs to disk, and then use the tika from_file() method to pull that download file from the disk to process. Example:
# Download ex.pdf to local disk
dbx.files_download_to_file('/my_local_path/ex_on_disk.pdf', '/my_dropbox_path/ex.pdf')
from tika import parser
parsed = parser.from_file('ex_on_disk.pdf')
The problem is that I'm planning on running this app on something like Heroku. I don't think I'm able to save anything locally and then access it again. I'm not sure how to get something from the Dropbox API that can be directly referenced by the tika wrapper to run the same as above. I think the PHP SDK has a file_get_contents and a file_put_contents set of methods but it doesn't appear to have a companion in the Python SDK.
I've tried using the shareable links in place of a filename but that hasn't worked. Any ideas? I know there's also the files_download method which downloads the FileMetadata object but I have no idea what to do with this and am having trouble finding more about it.
TLDR; How can I reference a file on Dropbox with a filename string such as 'example.pdf' to be used in another function that is trying to read a file from disk, without saving that Dropbox file to disk?
I figured it out. I used the files_download method to get the byte string and then use the from_buffer method of tika instead:
md, response = dbx.files_download(path)
file_contents = response.content
parsed = parser.from_buffer(file_contents)

When serving files with nginx , the browser shows the html file content in all javascript files

I have build a project on node, express,angular js and have deployed using nginx but when I see the source code in the browser , I find that all the javascript files are loaded with HTML content. What could be the possible reason.?enter image description here

Selenium Webdriver, Uploadify how to upload file using Node.js

Uploadify, not exist a input element, so cannot use sendKeys upload.
I have found how to upload a file using Java: (How to handle windows file upload using Selenium WebDriver?)
I want to know how upload file using Node.js?

Resources