Questions tagged [node.js-fs]

203 questions
0
votes
1 answer

fs module in node js fs.existsSync not recognising with Latin filename

I have some file names in "LATIN" but the fs.existsSync function is not able to recognise it 1689017335025-Naan En Nesarudaiyavan â mix.json I tired with buffer too but still not able to get the proper response. I am providing the proper path of the…
0
votes
1 answer

Using asynchronous Node.js functions with Python subprocesses

I have an app.js file that uses fs.watchFile() to check for changes in a text file. The changes are then outputed to the console. I have a python.py that I would like to use this JS file while the same time running code for the GPIO pins on a…
0
votes
0 answers

I am writing a mini library website with borrow and return post method using node js

I am trying to finish a homepage for a mini library website with these requirements. a left indented checkboxed form with title of the available books; has a button called borrow a right indented checkboxed form with title of the borrowed books;…
bubs
  • 1
  • 1
0
votes
0 answers

silent download of a file in a React app without showing it in the browser? (fs package not working)

I'm working on a React app where I need to initiate a file download without showing it in the browser. I've tried different approaches, but so far, the download always shows up in the browser, which is not the behavior I want. I need the download to…
Krisna
  • 2,854
  • 2
  • 24
  • 66
0
votes
1 answer

How fast is fs.readdirSync and can I speed it up?

I have a function that gets all the files in a directory recursively using fs.readdirSync. It works well with the small directory I ran it through as a test, but now that I am running this on a directory that is over 100GB large, it is taking a very…
Omi in a hellcat
  • 558
  • 1
  • 8
  • 29
0
votes
0 answers

openpgp.createMessage returns 2 promises in ReadStream; resulting in duplicate PGP armored encrypted files

With Below function, using OpenPGP.js, console.log(testMessage) produces 2 promises As such, the output from fileWriteStream produces PGP armored files which are duplicated/concatenated. Can someone solve this? async function…
0
votes
1 answer

Having issues adding to a pre-existing JSON file using Node Js fs

I am creating a system that logs "Infractions" in a JSON file for further use. However, whenever I use fs.writeFile to do som It just deletes the entire file and writes over it. I am trying to get it to add to the already stocked JSON file. Here's…
0
votes
2 answers

Node.JS on IBMi / OS400: filename with accents non accessible

I have a NodeJs (14 & 18) service which list and read files from the local filesystem, on IBMi or AS/400... I use: await fsPromises.readdir(mydir) for to list all files of my directory await fsPromises.readFile(filename) for to read the…
Didier68
  • 1,027
  • 12
  • 26
0
votes
2 answers

Adding newline characters in Node.js for file output

I'm working on a Node.js application and need to append newline characters to a file in a way that is valid and recognized by various text editors and tools(Specific for .bib files). I tried to add \n after each field. This is one case. const data =…
Paris
  • 23
  • 8
0
votes
0 answers

Convert BLOB of a image to a image file in nodejs

I am working on a api that fetches the image from the server and it is giving the image as blob and now i wanted to convert that blob to a image file and save locally I had tried to convert the image to base64 and then convert it to image and also…
iamkuna9
  • 11
  • 3
0
votes
0 answers

What is the best way to convert a chunk into writable stream for FFMPEG or FS.write?

I have a chunk of data and I use const blob = new Blob(chunks) to make into a blob and from a blob into an arrayBuffer with Buffer.from(await blob.arrayBuffer()) and then I make a stream from buffer with Readable.from(buffer); However the whole…
Hypothesis
  • 1,208
  • 3
  • 17
  • 43
0
votes
1 answer

Cannot open PDFKit generated file

I want to create a pdf file in my NodeJs server and then stream to the client, so it can download it, but I am not able to open the pdf file. I created a pdf file using PDFKit, using the code in the documentation: const doc = new…
0
votes
1 answer

Error: Module not found: Can't resolve 'fs' and 'path' in '@sendgrid/helpers/classes'

I'm trying to use the SendGrid module in my React application to send an email using a contact form. However, when I run npm start, I encounter the following error: Failed to compile. Module not found: Error: Can't resolve 'fs' in…
user22081405
0
votes
0 answers

Filesize is returned 0 on testing

I am reading file size of a file using fs.statSync on my application. When testing, fs.statSync returns size: 0. And when actually running the application, it runs fine and return some size as it is supposed to. Why could this be happening during…
cyclonejet
  • 41
  • 1
  • 6
0
votes
0 answers

Can't add to an object, when opening a file

Im kind of new to JavaScript and I wanted to open a text file, read from it to an object, then close it. I made an object like this: const users = { data: new Array() } And after this I've tried, to push the thisUser object to the data list of…
krusoadam
  • 13
  • 3