Questions tagged [createwritestream]

54 questions
1
vote
1 answer

node.js program crashes with too many writeStreams; other options?

I have data incoming every minute which I need to write to several files. My solution at the moment is: function writeData(data) { for(let i = 0; i < data.length; i++) { stream = fs.createWriteStream('myFile' + [i] + '.txt', {flags:…
1
vote
2 answers

How to wait for loop of stream.write() to end

I am using Node's fs.WriteStream to write data into files. I am looping through an array of objects and writing each object with the write() function. The problem is that I would like to know once this loop is over and all the write() calls are…
Pedro Dalla
  • 33
  • 1
  • 6
1
vote
1 answer

WriteStream nodejs out memory

I try to create a 20MB file, but it throws the error out of memory, set the max-old-space-size to 2gb, but still can someone explain to me why writing a 20mb stream consumes so much memory? I have 2.3 g.b of free memory let size=20*1024*1024;…
1
vote
1 answer

Unable to use one readable stream to write to two different targets in Node JS

I have a client side app where users can upload an image. I receive this image in my Node JS app as readable data and then manipulate it before saving like this: uploadPhoto: async (server, request) => { try { const…
LondonGuy
  • 10,778
  • 11
  • 79
  • 151
1
vote
1 answer

Google cloud storage uploads 0 Bytes Node.js

I am using Google-Cloud-Storage. This code will save an object in the bucket but it is just empty. It shows a size of 0 Bytes req.file = req.files.file; const bucketName = req.body.bucketName || DEFAULT_BUCKET_NAME; const bucket =…
1
vote
1 answer

Return From Async Function After Download and File Save are Complete in NodeJS

I have a sequence of events that go something like this: //Download a file and write it to disk await downloadSyncFile(user, downloadURL) //Use the file... await useTheFile() //Crash! The file is only partially there! Dangit! My code keeps moving…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
1
vote
2 answers

Javascript Promise not resolving for createWriteStream

I have tried many variations of getting my function to return a param so that I can run my functions only when one step is complete but looking for the best way that would not get me into call back hell. I have the following function function…
Afshin Ghazi
  • 2,784
  • 4
  • 23
  • 37
1
vote
1 answer

Can I get the Buffer from fs.createWriteStream()?

I have simple question - Can I get the Buffer from fs.createWriteStream()? In my case I use archiver NPM module which may create archives from Buffer. When this module end work with method archive.finalize() I may get result from…
HtmlMan
  • 45
  • 2
  • 9
1
vote
1 answer

Why is the data not being written to the file?

I am trying to create a file with dummy data. Since the file will be huge with 32^5 data points, I was using the write-stream. But I cannot see any data being written to the file. What could be the reason for this? const faker =…
Amanda
  • 2,013
  • 3
  • 24
  • 57
1
vote
0 answers

How to avoid last comma when adding json with fs.createWriteStream in nodeJS

I'm using fs.createWriteStream() to add JSON-data asynchronously to a file with file.write(JSON.stringify(data) + ","). So every json-object is followed by a comma. How can I avoid/remove the comma after the last json-object inside the…
Dennis L
  • 11
  • 1
1
vote
2 answers

node.js fs.createWriteStream creates the file, but cannot be written to with no error

I am attempting to catch 'Uncaught Exception's and write them to a file on the server. My code is: var cluster = require('cluster'); // The master's job to spawn workers initially and when they die if (cluster.isMaster) { // Get the number of…
James
  • 3,765
  • 4
  • 48
  • 79
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

createWriteStream do not fire an error event when the file is not fully written due to disk space

Here's the problem i'm facing with createWriteStream: Let's say I have a 100mb file, and i want to write it in another file on the disk the disk available size is 50mb my code: const fs = require('fs'); const w =…
0
votes
0 answers

BrightSign and Node.js 14.x EROFS: read-only file system

I need an answer on this magic question: I use fs.createWriteStream to write a text file to "storage/sd/" (as like at BrightSign documentations) and it is work good at first any times. After any times I'm starting to get the message "EROFS:…
0
votes
1 answer

fs.createWriteStream is streaming but not writing

I only recently noticed that the following code is not doing what it was doing earlier… actually writing the file to the disk. const download = async (archive) => { const d = await new Promise((resolve) => { const opts = { method:…
punkish
  • 13,598
  • 26
  • 66
  • 101