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

mock-aws-s3

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-aws-s3

Mock AWS S3 SDK for Node.js

  • 4.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
458K
increased by14.54%
Maintainers
1
Weekly downloads
 
Created

What is mock-aws-s3?

The mock-aws-s3 npm package is a mock implementation of the AWS S3 SDK, allowing developers to simulate interactions with AWS S3 in a local environment. This is particularly useful for testing and development purposes without incurring costs or requiring an actual AWS account.

What are mock-aws-s3's main functionalities?

Mocking S3 Bucket Creation

This feature allows you to mock the creation of an S3 bucket. The code sample demonstrates how to create a bucket named 'my-bucket' using the mock-aws-s3 package.

const AWS = require('mock-aws-s3');
const s3 = new AWS.S3();

s3.createBucket({ Bucket: 'my-bucket' }, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Mocking S3 Object Upload

This feature allows you to mock the upload of an object to an S3 bucket. The code sample demonstrates how to upload a string 'Hello, world!' to a bucket named 'my-bucket' with the key 'my-key'.

const AWS = require('mock-aws-s3');
const s3 = new AWS.S3();

const params = {
  Bucket: 'my-bucket',
  Key: 'my-key',
  Body: 'Hello, world!'
};

s3.upload(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Mocking S3 Object Retrieval

This feature allows you to mock the retrieval of an object from an S3 bucket. The code sample demonstrates how to retrieve an object with the key 'my-key' from a bucket named 'my-bucket' and log its content.

const AWS = require('mock-aws-s3');
const s3 = new AWS.S3();

const params = {
  Bucket: 'my-bucket',
  Key: 'my-key'
};

s3.getObject(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data.Body.toString()); // successful response
});

Other packages similar to mock-aws-s3

Keywords

FAQs

Package last updated on 10 Apr 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