L
L
LinuxGod2020-05-02 13:17:48
Node.js
LinuxGod, 2020-05-02 13:17:48

How to store files?

I have a project written in node.js.
I need to store files - and a lot, from the word A LOT OF FILES!
They should be sorted into directories in each directory with 1000 files, if a directory creates 999 files a new directory is created.
Are there any libraries, courses, reports on storing files using node.js in this case - forget about defragmentation, since these files will not need to be deleted.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2020-05-02
@LinuxGod

You don't need anything other than https://nodejs.org/api/fs.html . Do a readdir and if the array is >= 1000, create a new directory.
Or even easier store somewhere the total number of files. For example, you have 2423192 files already distributed, so the next one will go to the directory Math.floor(2423192 / 1000) = 2423

R
Roman Mirilaczvili, 2020-05-02
@2ord

Where and how to store many GB of images for a website?
Use SDK for access.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question