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

s3rver

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s3rver

Fake S3 server for node

  • 3.7.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is s3rver?

s3rver is a lightweight server that emulates the Amazon S3 API. It is useful for testing and development purposes, allowing developers to simulate S3 interactions without needing access to the actual AWS S3 service.

What are s3rver's main functionalities?

Start a local S3 server

This code snippet demonstrates how to start a local S3 server using s3rver. The server is configured to run on port 4569 and will store data in the /tmp/s3rver directory. It also pre-configures a bucket named 'my-bucket'.

const S3rver = require('s3rver');
const s3rver = new S3rver({
  port: 4569,
  address: 'localhost',
  directory: '/tmp/s3rver',
  configureBuckets: [{ name: 'my-bucket' }]
});
s3rver.run().then((server) => {
  console.log(`S3rver is running on ${server.address}:${server.port}`);
});

Upload a file to the local S3 server

This code snippet demonstrates how to upload a file to the local S3 server started by s3rver. It uses the AWS SDK to interact with the local S3 server, uploading a file named 'example.txt' to the 'my-bucket' bucket.

const AWS = require('aws-sdk');
const fs = require('fs');
const s3 = new AWS.S3({
  endpoint: 'http://localhost:4569',
  s3ForcePathStyle: true,
  accessKeyId: 'S3RVER',
  secretAccessKey: 'S3RVER'
});
const params = {
  Bucket: 'my-bucket',
  Key: 'example.txt',
  Body: fs.createReadStream('example.txt')
};
s3.upload(params, (err, data) => {
  if (err) {
    console.error(err);
  } else {
    console.log(`File uploaded successfully at ${data.Location}`);
  }
});

List objects in a bucket

This code snippet demonstrates how to list objects in a bucket on the local S3 server. It uses the AWS SDK to interact with the local S3 server and lists all objects in the 'my-bucket' bucket.

const AWS = require('aws-sdk');
const s3 = new AWS.S3({
  endpoint: 'http://localhost:4569',
  s3ForcePathStyle: true,
  accessKeyId: 'S3RVER',
  secretAccessKey: 'S3RVER'
});
const params = {
  Bucket: 'my-bucket'
};
s3.listObjectsV2(params, (err, data) => {
  if (err) {
    console.error(err);
  } else {
    console.log('Objects in bucket:', data.Contents);
  }
});

Other packages similar to s3rver

Keywords

FAQs

Package last updated on 03 Oct 2021

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