{"id":13989902,"url":"https://github.com/jamhall/s3rver","last_synced_at":"2025-07-22T11:32:08.251Z","repository":{"id":25362011,"uuid":"28789863","full_name":"jamhall/s3rver","owner":"jamhall","description":"A fake S3 server written in NodeJs","archived":false,"fork":false,"pushed_at":"2024-11-06T21:49:23.000Z","size":1283,"stargazers_count":573,"open_issues_count":56,"forks_count":149,"subscribers_count":15,"default_branch":"main","last_synced_at":"2024-11-06T22:33:59.703Z","etag":null,"topics":["amazon","amazon-s3","s3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamhall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-04T23:49:00.000Z","updated_at":"2024-10-13T16:06:21.000Z","dependencies_parsed_at":"2023-01-14T02:37:00.543Z","dependency_job_id":"a3cfcdc0-8d0d-4f8e-a276-e1839e209592","html_url":"https://github.com/jamhall/s3rver","commit_stats":{"total_commits":862,"total_committers":62,"mean_commits":"13.903225806451612","dds":0.4733178654292344,"last_synced_commit":"f834192dbb07da4548b48c95066bae50cfaac819"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamhall%2Fs3rver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamhall%2Fs3rver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamhall%2Fs3rver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamhall%2Fs3rver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamhall","download_url":"https://codeload.github.com/jamhall/s3rver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227089465,"owners_count":17729469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","amazon-s3","s3"],"created_at":"2024-08-09T13:02:09.359Z","updated_at":"2024-11-29T09:30:34.624Z","avatar_url":"https://github.com/jamhall.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# S3rver\n\n[![NPM](https://nodei.co/npm/s3rver.png)](https://nodei.co/npm/s3rver/)\n\n[![Build Status](https://api.travis-ci.org/jamhall/s3rver.png)](https://travis-ci.org/jamhall/s3rver)\n[![Dependency Status](https://david-dm.org/jamhall/s3rver/status.svg)](https://david-dm.org/jamhall/s3rver)\n[![Devdependency Status](https://david-dm.org/jamhall/s3rver/dev-status.svg)](https://david-dm.org/jamhall/s3rver?type=dev)\n\nS3rver is a lightweight server that responds to **some** of the same calls [Amazon S3](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html) responds to. It is extremely useful for testing S3 in a sandbox environment without actually making calls to Amazon.\n\nThe goal of S3rver is to minimise runtime dependencies and be more of a development tool to test S3 calls in your code rather than a production server looking to duplicate S3 functionality.\n\n## Supported methods\n\n### Buckets\n\n- Create bucket\n- Delete bucket\n- List buckets\n- List content of buckets (prefix, delimiter, marker and max keys, common prefixes)\n\n### Objects\n\n- Put object (support for metadata, including ContentEncoding (gzipped files)\n- Post object (multipart)\n- Delete object(s)\n- Get object (including using the HEAD method)\n- Get dummy ACLs for an object\n- Copy object (including updating of metadata)\n- Listen to Put, Copy, Post and Delete events.\n\n## Quick Start\n\nInstall s3rver:\n\n```bash\n$ npm install s3rver -g\n```\n\nYou will now have a command on your path called _s3rver_\n\nExecuting this command for the various options:\n\n```bash\n$ s3rver --help\n```\n\n## Supported clients\n\nPlease see [Fake S3's wiki page](https://github.com/jubos/fake-s3/wiki/Supported-Clients) for a list of supported clients.\nWhen listening on HTTPS with a self-signed certificate, the AWS SDK in a Node.js environment will need `httpOptions: { agent: new https.Agent({ rejectUnauthorized: false }) }` in order to allow interaction.\n\nIf your client only supports signed requests, specify the credentials\n\n```javascript\n{\n  accessKeyId: \"S3RVER\",\n  secretAccessKey: \"S3RVER\",\n}\n```\n\nin your client's configuration.\n\nPlease test, if you encounter any problems please do not hesitate to open an issue :)\n\n## Static Website Hosting\n\nIf you specify a [website configuration file](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html#RESTBucketPUTwebsite-examples),\nS3rver supports simulating S3's static website mode for incoming `GET` requests.\n\n### Hostname Resolution\n\nBy default a bucket name needs to be given. So for a bucket called `mysite.local`, with an indexDocument of `index.html`. Visiting `http://localhost:4568/mysite.local/` in your browser will display the `index.html` file uploaded to the bucket.\n\nHowever you can also setup a local hostname in your /etc/hosts file pointing at 127.0.0.1\n\n```\nlocalhost 127.0.0.1\nmysite.local 127.0.0.1\n```\n\nNow you can access the served content at `http://mysite.local:4568/`\n\n## Tests\n\nThe tests should be run by one of the active LTS versions. The CI Server runs the tests on the latest active releases.\n\nTo run the test suite, first install the dependencies, then run `npm test`:\n\n```bash\n$ npm install\n$ npm test\n```\n\n## Programmatically running s3rver\n\nYou can also run s3rver programmatically.\n\n\u003e This is particularly useful if you want to integrate s3rver into another projects tests that depends on access to an s3 environment\n\n## Class: `S3rver`\n\n### new S3rver([options])\n\nCreates a S3rver instance\n\n\u003c!-- prettier-ignore-start --\u003e\n| Option                         | Type                 | Default         | Description\n| ------------------------------ | -------------------- | --------------- | -----------\n| address                        | `string`             | `localhost`     | Host/IP to bind to\n| port                           | `number`             | `4568`          | Port of the HTTP server\n| key                            | `string` \\| `Buffer` |                 | Private key for running with TLS\n| cert                           | `string` \\| `Buffer` |                 | Certificate for running with TLS\n| silent                         | `boolean`            | `false`         | Suppress log messages\n| serviceEndpoint                | `string`             | `amazonaws.com` | Override the AWS service root for subdomain-style access\n| directory                      | `string`             |                 | Data directory\n| resetOnClose                   | `boolean`            | `false`         | Remove all bucket data on server close\n| allowMismatchedSignatures      | `boolean`            | `false`         | Prevent `SignatureDoesNotMatch` errors for all well-formed signatures\n| vhostBuckets                   | `boolean`            | `true`          | Allow vhost-style access for all buckets\n| configureBuckets\\[].name       | `string`             |                 | The name of a prefabricated bucket to create when the server starts\n| configureBuckets\\[].configs\\[] | `string` \\| `Buffer` |                 | Raw XML string or Buffer of Bucket config\n\u003c!-- prettier-ignore-end --\u003e\n\nFor your convenience, we've provided sample bucket configurations you can access using `require.resolve`:\n\n```javascript\nconst corsConfig = require.resolve('s3rver/example/cors.xml');\nconst websiteConfig = require.resolve('s3rver/example/website.xml');\n\nconst s3rver = new S3rver({\n  configureBuckets: [\n    {\n      name: 'test-bucket',\n      configs: [fs.readFileSync(corsConfig), fs.readFileSync(websiteConfig)],\n    },\n  ],\n});\n```\n\nAdditional references for defining these configurations can be found here:\n\n- CORS: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTcors.html\n- Static website: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html\n\n### s3rver.run(callback)\n\n### s3rver.close(callback)\n\nStarts/stops the server on the configured port and host. Returns a Promise if no callback is specified.\n\nExample in mocha:\n\n```javascript\nconst S3rver = require('s3rver');\nlet instance;\n\nbefore(function (done) {\n  instance = new S3rver({\n    port: 4569,\n    address: 'localhost',\n    silent: false,\n    directory: '/tmp/s3rver_test_directory',\n  }).run(done);\n});\n\nafter(function (done) {\n  instance.close(done);\n});\n```\n\n### s3rver.callback() ⇒ `function (req, res)`\n\n_Alias:_ **s3rver.getMiddleware()**\n\nCreates and returns a callback that can be passed into `http.createServer()` or mounted in an Express app.\n\n### s3rver.configureBuckets() =\u003e `Promise\u003cvoid\u003e`\n\nConvenience method for configurating a set of buckets without going through S3's\nAPI. Useful for quickly provisioning buckets before starting up the server.\n\n### s3rver.reset() =\u003e `void`\n\nResets all bucket and configurations supported by the configured store.\n\n## Subscribing to S3 Events\n\n### Event: `'event'`\n\nYou can subscribe to notifications for PUT, POST, COPY and DELETE object events in the bucket when you run S3rver programmatically.\nPlease refer to [AWS's documentation](http://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html) for details of event object.\n\n```javascript\nconst S3rver = require('s3rver');\nconst { fromEvent } = require('rxjs');\nconst { filter } = require('rxjs/operators');\n\nconst instance = new S3rver({\n  port: 4569,\n  address: '0.0.0.0',\n  silent: false,\n  directory: '/tmp/s3rver_test_directory',\n}).run((err, { address, port } = {}) =\u003e {\n  if (err) {\n    console.error(err);\n  } else {\n    console.log('now listening at address %s and port %d', address, port);\n  }\n});\n\nconst s3Events = fromEvent(instance, 'event');\ns3Events.subscribe((event) =\u003e console.log(event));\ns3Events\n  .pipe(filter((event) =\u003e event.Records[0].eventName == 'ObjectCreated:Copy'))\n  .subscribe((event) =\u003e console.log(event));\n```\n\n## Using [s3fs-fuse](https://github.com/s3fs-fuse/s3fs-fuse) with S3rver\n\nYou can connect to s3rver and mount a bucket to your local file system by using the following command:\n\n```bash\n$ s3fs bucket1 /tmp/3 -o url=\"http://localhost:4568\" -o use_path_request_style -d -f -o f2 -o curldbg\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamhall%2Fs3rver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamhall%2Fs3rver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamhall%2Fs3rver/lists"}