More util methods
Some more methods for the storage service.
Before finishing the StorageService
, let's just add two more methods there. Going back to it, we may write methods's signatures to:
Validate the amount of files to be saved into a directory
Generate a unique filename from the original one
And now, in the FseService
, implement them.
validateFilecount()
- Checks if the file count exceeds a maximum
genUniqueFilename()
- Prepends a filename with a unique prefix
The unique prefix was obtained from the Multer docs.
It's a good practice to save files with unique filenames.
Lastly, adjust the saveFile()
method to use the unique filename.
Commit - Some more features in file storage
Last updated