npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fc-store

v1.0.1

Published

File chunking, and storage with MongoDB

Downloads

15

Readme

FileChunk Storage

A lightweight Node.js package for splitting (chunking) files, encrypting and storing them in MongoDB, with support for reassembling and deleting files as needed.


📦 Installation

npm install fc-store

USAGE

const { MongoClient } = require("mongodb"); const path = require("path"); const { FileChunk } = require("fc-store");

async function init() { const mongodbClient = new MongoClient("mongodb://localhost:27017"); await mongodbClient.connect();

const db = mongodbClient.db("fileStorage"); const fileChunk = new FileChunk(db, "fileMeta", "fileData");

// Disassemble a file into chunks and store in MongoDB await fileChunk .disassembleFileFromPath(path.join(__dirname, "video.mp4"), 1024) .then(console.log) .catch(console.error);

// Reassemble a file from MongoDB and save it to disk const fileId = "f767b3984686e2c4fc70c403b02527"; await fileChunk .reassembleFileFromPath(fileId, 1024, __dirname, "video") .then(console.log) .catch(console.error);

// Delete a file and its chunks from MongoDB await fileChunk .deleteFile(fileId) .then(console.log) .catch(console.error);

await mongodbClient.close(); }

init().catch(console.error);

API Reference

disassembleFileFromPath(filePath, chunkSize?) Description: Splits a file into chunks and stores them in MongoDB.

Parameters:

filePath (string): Path to the input file.

chunkSize (number, optional): Size of each chunk in bytes. Default: 1024.

reassembleFileFromPath(fileId, chunkSize?, outputDir?, outputName?) Description: Reconstructs a file from chunks and saves it to disk.

Parameters:

fileId (string): Unique identifier of the file.

chunkSize (number, optional): Must match the original chunk size used. Default: 1024.

outputDir (string, optional): Target directory. Default: current directory.

outputName (string, optional): Name of the output file. Default: original name.

deleteFile(fileId) Description: Deletes all chunks and metadata related to a file.

Parameters:

fileId (string): Unique identifier of the file to delete.

Notes

Make sure MongoDB is running and accessible at the specified URI.

The chunkSize parameter is optional in both disassembleFileFromPath and reassembleFileFromPath. Default is 1024 bytes.

Suitable for storing and reconstructing large files (e.g., videos, images, backups).

Example Use Cases

Uploading large files to a MongoDB-backed service.

Creating resumable file uploads/downloads.

Efficient storage of binary blobs.

License

MIT


Let me know if you'd like to add badges, CI/CD info, or an example repo link.