Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
skipper-disk
Advanced tools
Local filesystem adapter for receiving streams of file streams. Particularly useful for streaming multipart file uploads via Skipper.
This module is bundled as the default blob adapter in Skipper, and consequently Sails.
========================================
$ npm install skipper-disk --save
========================================
First instantiate a blob adapter (blobAdapter
):
var blobAdapter = require('skipper-disk')();
Build a receiver (receiving
):
var receiving = blobAdapter.receive();
Then stream file(s) from a particular field (req.file('foo')
):
req.file('foo').upload(receiving, function (err, filesUploaded) {
// ...
});
========================================
All options may be passed either into the blob adapter's factory method:
var blobAdapter = require('skipper-disk')({
// These options will be applied unless overridden.
});
Or directly into a receiver:
var receiving = blobAdapter.receive({
// Options will be applied only to this particular receiver.
});
Option | Type | Details |
---|---|---|
dirname | ((string)) | The path to the directory on disk where file uploads should be streamed. May be specified as an absolute path (e.g. /Users/mikermcneil/foo ) or a relative path from the current working directory. Defaults to ".tmp/uploads/" |
saveAs() | ((function)) | An optional function that can be used to define the logic for naming files (with callback optional). For example: function (file) {return Math.random()+file.name;} or function (filename,cb) {foo.asyncall(function(err,result){ options.filename = result[0]; cb(null)}); } By default, Skipper-disk generate a random-Number for filename on your disk (e.g. 24d5f444-38b4-4dc3-b9c3-74cb7fbbc932.jpg) - that is given as "id" in upload()-callback. |
========================================
upstream.pipe(receiving)
As an alternative to the upload()
method, you can pipe an incoming upstream returned from req.file()
(a Readable stream of Readable binary streams) directly to the receiver (a Writable stream for Upstreams.)
req.file('foo').pipe(receiving);
There is no performance benefit to using .pipe()
instead of .upload()
-- they both use streams2. The .pipe()
method is available merely as a matter of flexibility/chainability. Be aware that .upload()
handles the error
and finish
events for you; if you choose to use .pipe()
, you will of course need to listen for these events manually:
req.file('foo')
.on('error', function onError() { ... })
.on('finish', function onSuccess() { ... })
.pipe(receiving)
========================================
See CONTRIBUTING.md
.
========================================
MIT © 2013, 2014-
Mike McNeil, Balderdash & contributors
See LICENSE.md
.
This module is part of the Sails framework, and is free and open-source under the MIT License.
FAQs
Receive streaming file uploads on your local filesystem.
The npm package skipper-disk receives a total of 20,301 weekly downloads. As such, skipper-disk popularity was classified as popular.
We found that skipper-disk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.