
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Convenience layer for Mongo's GridFS on Node.js applications
This module uses Aaron Heckmann's gridfs-stream module to stream data into GridFS.
npm install --save tl-gridfs
var gridfs = require('tl-gridfs');
You must initialize it with your current Mongo instance and db connection before using it:
gridfs.init(db, mongo);
If you're using mongoose, just pass mongoose.connection.db
and mongoose.mongo
:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/your-db-name', options);
mongoose.connection.on('error', function (err) {
throw err;
});
mongoose.connection.once('open', function () {
gridfs.init(mongoose.connection.db, mongoose.mongo);
});
You can write from a path String
pointing to a file, a Stream.Readable
object created from the fs
module or a Buffer
.
You can define your source as a String
:
var source = '/path/to/the/file.ext';
As a Stream.Readable
:
var source = fs.createReadStream('/path/to/the/file.ext');
Or as a Buffer
:
var source = new Buffer('important buffer data here');
And then save it to GridFS with:
gridfs.write(source, function (err, fsfile) {
if (err) {
throw err;
}
/* Do whatever you want with your fsfile */
console.log("The file %s named %d has a length of %d", fsfile._id, fsfile.filename, fsfile.length);
});
A common fsfile Object
should look like this:
{
_id: ObjectId,
filename: String,
contentType: String,
length: Number,
chunkSize: Number,
uploadDate: Date,
aliases: Object,
metadata: Object,
md5: String
}
To read a file you must provide a String
than can be either a valid ObjectId
or a file name.
So, you can define your file as an ObjectId
:
var file = '55a52e49a562f0bb2627f38e';
Or as a file name:
var file = 'secret_document.docx';
And then get access to the file with:
gridfs.read(file, function (err, fsfile, rs) {
if (err) {
throw err;
}
/* Now you have your fsfile object and a nice read stream */
});
The rs
parameter is a Stream.Readable
object that can be piped, written or anything that Stream.Readable
's can do.
To remove a file you must provide a String
than can be either a valid ObjectId
or a file name.
You can remove the file via it's ObjectId
:
var file = '55a52e49a562f0bb2627f38e';
Or it's file name:
var file = 'secret_document.docx';
And then remove the file with:
gridfs.remove(file, function (err) {
if (err) {
throw err;
}
/* File has been removed */
});
FAQs
Convenience layer for Mongo's GridFS on Node.js applications
The npm package tl-gridfs receives a total of 0 weekly downloads. As such, tl-gridfs popularity was classified as not popular.
We found that tl-gridfs 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.