Function like `tmp.open` to create write stream.
See original GitHub issuetmp.file
has some nice advantages (implicit mode and exclusive) but code using the file descriptor from fs.open
is rare nowadays.
An alternate version that would return a stream made with fs.createWriteStream
would be nice.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:19 (1 by maintainers)
Top Results From Across the Web
How to use fs.createWriteStream? - Node.js
createWriteStream () function opens a file for writing. The file is created (if it does not exist) or truncated (if it exists). Since...
Read more >event associated with fs.createWriteStream in node.js
What event is triggered when EOF is reached while writing to a stream ? My code is as follows. and it ...
Read more >Understanding Streams in Node.js - NodeSource
The function call fs.createReadStream() gives you a readable stream. Initially, the stream is in a static state. As soon as you listen to...
Read more >Write Data to File Using fs.createWriteStream() - YouTube
In this Video, we looked at how we can write data to a file, pipe data from one file to another using a...
Read more >fs.rename(path1, path2, [callback]) : nodejs API - GitHub Pages
WriteStream is a Writable Stream. Event: 'open' #. function (fd) { }. fd is the file descriptor used by the WriteStream.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dantman I see where you are getting at, would the following API extension suffice?
I think that registering event listeners should be left to the client, e.g. error event listener that will automatically cleanup the tmp file and so on…
Problems here might be:
Calling the above API multiple times will likely cause an error with the default flags… Would it not suffice that tmp.fileSync() used these flags and possibly failed if the path did already exist, and use createWriteStream as it is, with only the “w+”?
In addition w+ will still truncate the tmp file, do you want this to happen? I think that a+ is the better choice here, is it not?
Huh? No, I want to be able to create a write stream for a temporary file the same way I would create an open fd for a temporary file. With the exact same behaviour. ie: Without suddenly being forced to declare
_c.O_CREAT | _c.O_EXCL | _c.O_RDWR
and the defaultmode
myself on a nodejs fs call.