Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
file-manager
Advanced tools
This simple module is designed to be an abstraction for file storage. By default, it saves files to disk in a specified directory, but it can easily be overridden to save files to anywhere you want, e.g. a database.
storageDirectory
- The directory on the local disk where files will be stored. Use null
to disable local disk storage.const FileManager = require('file-manager');
const Path = require('path');
let manager = new FileManager(Path.join(__dirname, 'data'));
Returns true
if either a storage directory is set, or if save and read handlers have been registered.
filename
- Obviouscontents
- Either a Buffer
, or some other value that will have .toString()
called on it, then it will be converted to a Buffer
by interpreting the string as UTF-8Saves a file. Returns a Promise
that will be fulfilled once the file is saved, or rejected if there's an error.
Alias: writeFile
files
- An object where keys are filenames and values are file contentsSaves multiple files. Returns a Promise
that will be fulfilled once all files are saved, or rejected if there's an error saving any file
Alias: writeFiles
filename
- ObviousReads a single file. Returns a Promise
that fulfills to its content, as a Buffer
. Rejects if there's an error or the file doesn't exist.
filenames
- Array of filenamesReads multiple files. Returns a Promise
that fulfills to an array containing objects of this structure:
filename
- The name of this filecontents
- The content of this file, if reading succeedederror
- An Error
object, if there was an error reading this file (e.g. it doesn't exist)This function can never reject.
You can register your own save/read handlers by attaching event listeners.
filename
- The filename of the file we want to readcallback
- A function you should call once this file's contents are available, or an error occurred
err
- An Error
object if there was an error reading this file (e.g. it doesn't exist). null
if no error.contents
- A Buffer
containing the file's content, if reading succeededEmitted when a file is requested to be read.
filename
- The filename of the file we want to savecontents
- The content we want to save to this file, as a Buffer
callback
- A function you should call once this file has been saved, or an error occurred
err
- An Error
object if there was an error saving this file. null
if no error.Emitted when a file is requested to be saved.
The local disk storage directory location can be changed at any time by assigning to the directory
property.
FAQs
File storage to disk, with optional handlers to redirect storage
The npm package file-manager receives a total of 40,507 weekly downloads. As such, file-manager popularity was classified as popular.
We found that file-manager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.