Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fake-s3

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fake-s3

a fake s3 server for testing purposes

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-67.44%
Maintainers
1
Weekly downloads
 
Created
Source

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/'
})

// starts the server on specified port
server.bootstrap((err) => {
  // handle err

  // this field now exists and contains the actual hostPort
  server.hostPort
})

// can wait for files
server.waitForFiles('my-bucket', 2, (err, files) => {
  // will call you back when two files have been uploaded
})

// shutdown server
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

  • Raynos

MIT Licensed

FAQs

Package last updated on 15 Mar 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc