npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@smcloudstore/aws-s3

v0.2.1

Published

AWS S3 library for SMCloudStore

Downloads

183

Readme

@smcloudstore/aws-s3

This package is a provider for SMCloudStore, for AWS S3. SMCloudStore is a lightweight Node.js module that offers a simple API to interact with the object storage services of multiple cloud providers.

Please refer to the main package for the SMCloudStore documentation and instructions on how to use it.

Provider-specific considerations

There are a few provider-specific considerations for the AwsS3 provider.

Connection argument

When initializing the AwsS3 provider, the connection argument is an object with:

  • connection.accessKeyId: string containing the access key ID (the "public key")
  • connection.secretAccessKey: string containing the secret access key (the "secret key")
  • connection.region (optional): string containing the AWS region to use. List of regions is available on the AWS documentation. Defaults to US Standard (Virginia) if not specified.

Example:

// Require the package
const SMCloudStore = require('smcloudstore')

// Complete with the connection options for AWS S3
const connection = {
    accessKeyId: 'PUBLIC_KEY_HERE',
    secretAccessKey: 'SECRET_KEY_HERE',
    region: 'us-west-1'
}

// Return an instance of the AwsS3Provider class
const storage = SMCloudStore.create('aws-s3', connection)

Creating a container

When using the storage.createContainer(container, [options]) and the storage.ensureContainer(container, [options]) methods, the options argument can be used to define some options for the container:

  • options.access (optional): string determining the default ACL for the container. Accepted values are listed below, and please refer to the documentation for more details:
    • 'public-read' (alias 'public' for compatibility with other storage providers)
    • 'public-read-write'
    • 'authenticated-read'
    • 'private' (alias 'none' for compatibility with other storage providers)), this is the default value.

Uploading an object

With the AWS S3 provider, the storage.putObject(container, path, data, [options]) method comes with a few more keys for the options dictionary, in addition to the standard options.metadata key:

  • options.access (optional): string determining the ACL for the object. Accepted values are listed below, and please refer to the documentation for more details:
    • 'public-read' (alias 'public' for compatibility with other storage providers)
    • 'public-read-write'
    • 'authenticated-read'
    • 'private' (alias 'none' for compatibility with other storage providers)), this is the default value.
  • options.serverSideEncryption (optional): when true, enables AES256 encryption at rest with keys managed by AWS. Default value is false (disabled).
  • options.class (optional): string represeting the storage class to use. Please see the documentation](https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html) for details; possible values are:
    • 'STANDARD'
    • 'REDUCED_REDUNDANCY'
    • 'STANDARD_IA'
    • 'ONEZONE_IA'

Using pre-signed URLs

In the method storage.presignedPutUrl(container, path, [options], [ttl]), the AWS S3 provider accepts for the options argument the same dictionary as the 'storage.putObject(container, path, data, [options])' method. If you specify a Content-Type in the request for the presigned URL, for example, clients will need to make PUT requests with the same Content-Type.

Accessing the AWS-SDK

The AWS S3 provider is built on top of the official AWS SDK for JavaScript, which is exposed by calling storage.client().

You can use the object returned by this method to perform low-level operations using the AWS S3 SDK. Note that only the S3 library is loaded, and not the full AWS SDK for JavaScript.