Questions tagged [node.js-fs]

203 questions
1
vote
1 answer

fs.existsSync false positive result

I'm working on a relatively simple node app and using fs to help write files and folders. One of checks I need to do is see if a folder already exists, and it does, stop as I don't want to overwrite others. I wrote a small function to check if the…
TimLavelle
  • 81
  • 7
1
vote
1 answer

Save canvas data as png or jpg in Tauri using fs module

I want to save my canvas data to file using the Tauri fs module. This is my code, but it didn't work. const { writeBinaryFile, BaseDirectory } = window.__TAURI__.fs; var canvas = document.getElementById("myCanvas"); var ctx =…
1
vote
2 answers

Collect a field value into an array by ID field in an object array

I am unable to modify JSON file. Tried to use all my knowledge of loops (map,filter) and conditions(if,else) JavaScript. But nothing comes out. Please tell me how to make such a file from this file [{ "model": "2002R \"Protection Pack - Mirage…
SharpLon
  • 15
  • 6
1
vote
1 answer

Node.js: should reject with an error if the passed data is invalid

I'm getting a problem while running the test cases using the node.js application where I'm creating a directory if not exists, writing the json and reading the file. Here's the Working Demo Link It's throwing the below error even after handling the…
Subhojit
  • 1,389
  • 8
  • 19
  • 33
1
vote
0 answers

Process file uploaded with a fetch post request with request.on in node js

I have a server that gets a file being uploaded from a html page and stores the file in a writable stream, but if the file is a little big, it creates multiple buffers and i have to create an array to store all the buffers and concat them later,…
1
vote
1 answer

How can I get the location of my screenshot made from video with ffmpeg in Node.js?

This is how I did it. const ffmpegPath = require('@ffmpeg-installer/ffmpeg'); import ffmpeg from 'fluent-ffmpeg'; import path from 'path'; const os = require('os'); ffmpeg.setFfmpegPath(ffmpegPath.path); export const generateThumbnailFromVideo =…
Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36
1
vote
1 answer

Exported Module Returning Object Promise -- calling fs.readFile as a module

I wrote a simple module that reads a file called readHistory.js: const fs = require('fs'); async function readHistory(history){ fs.readFile("history_file.txt", function read(err, data) { if (err) { throw err; } …
Z-Man Jones
  • 187
  • 1
  • 12
1
vote
2 answers

fs.createWriteStream cut file to 1mib

I use NestJS and fastify for my api-server. For files uploading used @fastify/multipart. This is what the function for downloading a file looks like async uploadFile(path, file): Promise { const normalPath =…
Vladimir
  • 53
  • 1
  • 5
1
vote
2 answers

i am using whatsapp chat export .i made it as a Json.i want store continuos messages as one message in NodeJs

i have a whatsapp chat export i want to make the continuos messages as single message the messages are given below i want to make the continuos messages as single message My NodeJs code in this code i read the data from txt file a store in…
MassEdits
  • 21
  • 5
1
vote
1 answer

Trying to write to a external json file using fs and express

I'm trying to write an object to a JSON, when passing the data through to the server I keep receiving this error and I cannot seem to find a solution to fix it... Here is my code APP.post('/api', (req, res) => { const data = req.body; …
Cameron Shearer
  • 142
  • 1
  • 10
1
vote
1 answer

copying large file line by line is not exact

I'm trying to correctly read and write 1 million lines from the pile corpora with node.js. The problem is that I get an output file with one million lines but the 1 millionth line is the 900kish line of the original file. This what I used: fs…
user3776738
  • 214
  • 2
  • 10
  • 27
1
vote
1 answer

How to convert a buffer to a readable file in NodeJS

I receive a buffer through an input: const fileData = Buffer.concat(chunks); I then send this input into OpenAI's Whisper which excepts a file const resp = await openai.createTranscription( //@ts-ignore fileData, "whisper-1", ); This doesn't…
1
vote
0 answers

Writing a byte buffer at a specific offset within the file in Java. (Equivalent of NodeJs fs.write )

I need to write bytes to a file from multiple threads in java, at a specific offset of the file. The fs.write from NodeJS takes the next arguments: fs.write(fd, buffer, offset, length, position, callback) The "position" argument reffers to the…
xplore
  • 11
  • 1
1
vote
1 answer

how to find largest and smallest .c files in directory

I'm trying to find the size of the largest and smallest .c files in the linux kernel fs directory. Here's what I have: find . -type f -name '*.c' | du -ah | sort -nr | head -10 That just gives me a list of the 10 largest files in the directory, but…
canor421
  • 11
  • 2
1
vote
1 answer

pdfmake is returning undefined

I am using pdfmake package to generate pdf, but when I am testing it on postman it says undefined. My app.js - const express = require('express') const bodyParser = require('body-parser') const path = require('path') const port = 9003 const app =…
Zain Chris
  • 31
  • 2
1
2
3
13 14