fake-s3
a fake s3 server for testing purposes.
This module uses s3rver
which does most of the heavy lifting.
The actual files uploaded to S3 are persisted to disk in
os.tmpdir()
Example
var FakeS3 = require("fake-s3");
var server = new FakeS3({
port: 0,
buckets: ['my-bucket'],
prefix: 'files-i-care-about/'
})
server.bootstrap((err) => {
server.hostPort
})
server.waitForFiles('my-bucket', 2, (err, files) => {
})
server.close()
Docs
var server = new FakeS3(options)
options.port
: the port to lsiten on, defaults to 0
options.hostname
: host to listen on, defaults to localhost
options.silent
: passed through to s3rver
, defaults to true
options.prefix
: prefix for getFiles()
and waitForFiles()
;
necessary to support multi part uploads, otherwise
waitForFiles()
will return too early when N parts have
been uploaded.options.buckets
: an array of buckets to create.
server.hostPort
This is the hostPort
that the server is listening on, this
will be non-null after bootstrap()
finishes.
server.bootstrap(cb)
starts the server
getFiles(bucket, cb)
gets all files in a bucket
waitForFiles(bucket, count, cb)
this will wait for file uploads to finish and calls getFiles()
and returns them once it's finished.
This is useful if your application does background uploads and you
want to be notified when they are finished.
server.close()
closes the HTTP server.
Installation
npm install fake-s3
Tests
npm test
Contributors
MIT Licensed