fs.readFile from local path in node.js
Posted: Mon Jan 10, 2022 4:45 pm
My Switch Server runs on Windows. I want to read a *.pdf locally to upload it later in a form data API Call.
I want to define a path to "C:/Users/username/Documents/Scripts/pdfsforupload/mypdf.pdf".
Is it correct to use this syntax?
Does Switch have access to this folders or is it better to read it from a smb share?
And if I would read from ./ would this be the folder where the script is in or the installation folder of switch?
When I try to read a pdf file like that I get a UNKNOWN: unknown error, open '//Users/username.....
Outside of switch on my mac with Node.js v14.17.0. this works and I get the Buffer and filestream logged to the console.
Any hints?
I want to define a path to "C:/Users/username/Documents/Scripts/pdfsforupload/mypdf.pdf".
Is it correct to use this syntax?
Code: Select all
const file = fs.readFileSync(`//Users/username.domain/Documents/Scripts/pdfforupload/${fileName}`)
Does Switch have access to this folders or is it better to read it from a smb share?
And if I would read from ./ would this be the folder where the script is in or the installation folder of switch?
When I try to read a pdf file like that I get a UNKNOWN: unknown error, open '//Users/username.....
Outside of switch on my mac with Node.js v14.17.0. this works and I get the Buffer and filestream logged to the console.
Any hints?