A
A
Alexander Degtyarev2019-06-27 17:39:30
JavaScript
Alexander Degtyarev, 2019-06-27 17:39:30

How to insert text at an arbitrary location in a file using createWriteStream in NodeJS?

Tell me, in the API, createWriteStreamthere is, option > {start: position, flags: "a"}but all the contents in the file are replaced and not inserted into a specific place.
I insert data using stream.write('Данные которые нужно вставить')
how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2019-06-27
@alexdeg

Files are arranged in such a way that it is impossible to insert something into them in some place without overwriting what was in this place.
In order not to overwrite the entire file at the same time (but only what was in a certain place) - open it in r + mode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question