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

metalsmith-s3

v0.1.0

Published

A Metalsmith.io plugin to integrate with AWS S3

Downloads

286

Readme

metalsmith-s3

Metalsmith plugin for reading/writing/copying files on AWS S3.

Example usage: nonLinear.zone build process.

Installation

$ npm install metalsmith-s3

Usage

var Metalsmith = require('metalsmith');
var s3 = require('metalsmith-s3');

var metalsmith = new Metalsmith(__dirname)
  .use(s3({
    action: 'copy',
    bucket: 's3-bucket-dest',
    from: 's3-bucket-src',
    prefix: ['images/', 'js/']
  }));
  .use(s3({
    action: 'read',
    bucket: 's3-bucket-src',
    ignore: ['images/', 'js/']
  }));
  ...
  .use(s3({
    action: 'write',
    bucket: 's3-bucket-dest'
  }));

S3 Library Pass Through

You can pass through additional settings directly to the s3 library by adding an s3 key and hash. Properties available vary based on the chosen action:

Example to set the ACL for files written to s3:

var Metalsmith = require('metalsmith');
var s3 = require('metalsmith-s3');

var metalsmith = new Metalsmith(__dirname)
  ...
  .use(s3({
    action: 'write',
    bucket: 's3-bucket-dest'
    s3: {
      ACL: 'public-read'
    }
  }));

Region Override

In case you face the following error, just add the optional parameter region :
TypeError: Error: PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

Applicable regions are listed in aws documentation.
Usage example:

.use(s3({
  action: 'write',
  bucket: 's3-bucket-dest',
  region: 'eu-west-1'
}));

Actions

Read

The read action will read files from an S3 bucket which can then be processed by plugins later in the chain. The read action can be modified to ignore certain prefixes in the S3 bucket be setting the ignore to a prefix, or an array of prefixes.

Read Parameters:

bucket: source S3 bucket
ignore: a prefix or array of prefixes not to be read from the source S3 bucket
region: bucket's endpoint region (optional)

Copy

The copy action will copy files from a source S3 bucket to a destination S3 bucket. The copy action must include a prefix parameter to specifiy one or more prefixes to be processed.

Copy Parameters

bucket: destination S3 bucket
from: source S3 bucket
prefix: a prefix or array of prefixes to be copied from the source S3 bucket
region: bucket's endpoint region (optional)

Write

The write action will write all files to the destination S3 bucket.

Write Parameters

bucket: destination S3 bucket
region: bucket's endpoint region (optional)

Mime Types

Uploaded file's mime type will be set by:

  • mimeType property in the file's meta, if set
  • type determined by mime-type's inspection of the file name
  • undefined (interpreted as application/octet-stream by S3)

Credentials configuration

Via environment variables

export AWS_ACCESS_KEY_ID='your_access_key'
export AWS_SECRET_ACCESS_KEY='your_secret_key'

Via configuration file

Create a credentials file at ~/.aws/credentials on Mac/Linux or C:\Users\USERNAME\.aws\credentials on Windows

[default]
aws_access_key_id = your_access_key
aws_secret_access_key = your_secret_key

TODO

  1. Test suite

#License

The MIT License (MIT)

Copyright © 2015, Matthew Wishek <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.