# filedump

> Store files

Latest version **0.0.6** (published 2014-06-23) · 0 weekly downloads

## Install

```sh
npm install filedump
pnpm add filedump
yarn add filedump
bun add filedump
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2014-06-23 |
| First published | 2014-03-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 0.10.26 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sebastian Vollnhals |
| Maintainers | yetzt |
| Keywords | file, files, storage, filestorage, store, filestore, upload, filesystem |

## Links

- npm: https://www.npmjs.com/package/filedump
- Repository: https://github.com/yetzt/node-filedump
- Issues: https://github.com/yetzt/node-filedump/issues
- npm.io page: https://npm.io/package/filedump

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.0.6 (latest) — 2014-06-23
- 0.0.5 — 2014-04-19
- 0.0.4 — 2014-04-19
- 0.0.3 — 2014-03-26
- 0.0.2 — 2014-03-26
- 0.0.1 — 2014-03-26

## README

# filedump

Store files, buffers or readble streams in the filesystem with an automatically generated random filename and divided in folders to circument file system limitations. 

## Install

````
npm install filedump
````

## Usage

```` javascript
var filedump = require("filedump")("/path/to/storage", 20);

/* file in the filesystem */
filedump.save("/some/file.ext", function(err, filename){
	if (err) return console.error(err);
	console.log(filename);
});

/* buffer */
filedump.save(new Buffer("data"), "txt", function(err, filename){
	if (err) return console.error(err);
	console.log(filename);
});

/* readble stream */
var rs = require("fs").createReadStream("/some/file.ext");
filedump.save(ts, "txt", function(err, filename){
	if (err) return console.error(err);
	console.log(filename);
});
````

## API

### filedump(path, len)

* `path` points to the folder where the files are stored
* `len` is the length of the random generated string the directories and file name is derived from

### filedump.save(data, [ext], callback)

Save data and call back with filename when file is written

* `data` can be a file path, buffer or readble stream
* `ext` is the file extention for the generated file. this is automatically determined when the first argument is a file path
* `callback` has `err` and `filename` as arguments

### filedump.dump(data, [ext], callback)

Save data and call back with filename _before_ file is written and _without error reporting_

* `data` can be a file path, buffer or readble stream
* `ext` is the file extention for the generated file. this is automatically determined when the first argument is a file path
* `callback` has `err` and `filename` as arguments

### filedump.prepare([ext], callback)

Generate random file name, create directories and call back with file name

* `ext` is the file extention for the generated file. this is automatically determined when the first argument is a file path
* `callback` has `err` and `filename` as arguments

### filedump.delete(file, callback)

Delete a file and clear its parent directories.

* `file` is the file name relative to the storage folder
* `callback` has `err` as an argument

## License

[Public Domain](http://unlicense.org/UNLICENSE)

---
_Source: https://npm.io/package/filedump · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
