Questions tagged [node.js-fs]

203 questions
0
votes
0 answers

FS.writefile returning INVALD_ARG error when writing a string

fs.writefile is confusing the "alltimeplayers" variable for a different data type than a string. When "alltimeplayers" is logged to console, it is written as a string. The fs is imported with the code var fs = require('fs') Node.JS is installed…
0
votes
1 answer

DB.js refuses to hide {null} using DB.write(null,'etc','etc')

I'm storing key-value pairs as plaintext: headerlessKey=blahblahblah {partName} keyName=value If I put null/undefined as first parameter the key should not have a parent part: DB.write(null,'headerlessKey','hello…
0
votes
0 answers

I can not upload my image file with the CreateWriteScream method in the console it is written to me: The "path" argument must be of type string

I work with nodejs on a social network project I am on the part of the image upload for the profile photo and to do this I installed the multer module more precisely, version 2.0.0-rc.1.So I set up a file upload.controller.js and a file routes.js…
0
votes
1 answer

NEST.js service method for returning JSON from files

I am building a simple NEST api, just to learn stuff. In it there is a service which has a method called 'getTestFileAsJSON'. I am trying to build this api for a blog. There will be articles, which are files in the .txt format. I am trying to write…
slav.getov
  • 15
  • 7
0
votes
0 answers

How to track content when line is clicked and line is left

I am writing a VSCode Extension that tracks code progress in a .csv file. For now everytime I change from one line to another it gets tracked as a change into the .csv file, even if the content in the line did not change. The .csv file should only…
0
votes
0 answers

NestJS working with repository and fs in one transaction

I have NestJs api for e-books service Please help me for one question. How can I delete file and update database entity in one transaction, for prevent case when file was been deleted, but database entity update had error? public async…
0
votes
0 answers

nodejs streams file system

I have created a readstream whose default readableHighWaterMark value if 65536 and also created write stream whose default writableHighWaterMark value is 16384 and Iam sending data from readstream to writestream but when I am debugging and the…
0
votes
0 answers

write large csv in small chunks in node js

I am calling my 5 CSV URL get data from it and try to store all five csv return data from URL in one file but I have to write header once in file. For that I am converting my CSV to JSON and handle header thing and after that convert json to CSV…
Hard
  • 105
  • 5
0
votes
1 answer

fs.readFileSync not working in node.js create server

I know that this question is many.But mine is a little hard. I'm new to fs and i wanna read a file from txt and send it to client when it gives me a GET request and when it gives me a POST request. Sending the request is completly fine as i checked…
AlirezaBest
  • 103
  • 7
0
votes
0 answers

fs: Best way of mutual/asynchronous read/write to single file

Consider some kind of API scenario where I have one file that different HTTP requests cause reading/writing to. The requests occur synchronously. To avoid data or file access conflicts, I implemented some kind of asynchronous promise chain,…
DonFuchs
  • 371
  • 2
  • 14
0
votes
0 answers

Unexplained creation of newlines inside fs.writeFileSync

I'm making something that tracks something in a csv file. The csv file has a specific format that I need to adhere to. Each time changes are made, the file gets completely rewritten because I edit the middle of the file as well. To do this, I'm…
Treyara
  • 47
  • 1
  • 7
0
votes
2 answers

Typescript callback parameter with specific type?

I am new to TypeScript and I am trying to understand how to define the callback for a function of which the callback must have a parameter type but i don't know the correct syntax for it. This is my current function: function LoadJSON(callback:…
WDUK
  • 1,412
  • 1
  • 12
  • 29
0
votes
1 answer

Serve Image from mongodb using nodejs using pathname

I want to serve image from mongodb order product schema. I am uploading the image using fs and saving the relative path. I do not want to use multer. Here is my data that I am sending into the emailtemplate "product": { "id":…
0
votes
1 answer

How do I save a axios POST res / binary stream as a file?

I am using node.js, axios, an fs. I am hitting the vanceai.com api. And when I write the file I am getting a bad file. Code: export const imageDownloader = async (transId, name, ext) => { let data = qs.stringify({ 'api_token':…
0
votes
0 answers

Javascript code to read a text file, look for a match, and then assign a value based on that match

I'm hoping to get some help with the last piece of my extension. I've been working on a JS code that searches a dictionary based on user input from a text area and returns a match. That match is then assigned a series of values which are then put…