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

simple-s3-uploader

v1.1.7

Published

Simple AWS S3 file uploader.

Downloads

8

Readme

Simple S3 Uploader

Required params

  • bucket - Bucket name
  • key - S3 Access Key ID
  • secret - S3 Secret Access Key
  • remote - Path in your bucket to upload files. Ex.: /, /data/
  • source - Path from source files relative to your project root.

Optional params

  • region - Default: 'us-east-1'
  • cache - Default: 'max-age=604800' (7 days)

Usage

npm i simple-s3-uploader --save
const SimpleS3Uploader = require('simple-s3-uploader')

const params = {
  bucket: 'your-s3-bucket',
  key: 'your-s3-access-key-id',
  secret: 'your-secret-access-key',
  remote: 'bucket-folder-path',
  source: 'local-folder-path',
  region: 'your-s3-bucket-region',
  cache: 'string-max-age' 
}

await SimpleS3Uploader(params)

Returns a Promisse with an array of uploaded files.

Test

To test your connection with AWS the script will list the bucket. For this test all required params need to be filled.

$ npm test bucket="{bucket}" key="{key}" secret="{secret}" remote="{remote}" source="{source}" 

Securety

Don't store your key and secrets inside your JS files, unless you know what are you doing!

You can store this informations inside an API and request it from your JS file.

Another approach is create a JS file and get all this information from your CI service and pass it throght parameters. There it is an example to catch this parameters.

const path = require('path')
const SimpleS3Uploader = require('simple-s3-uploader')

let argv = {}

process.argv.forEach((val, index) => {
  const prop = val.split('=')[0]
  const ct = val.split('=')[1]

  if (!ct || ct === undefined) return;
  argv[prop] = ct
})

let config = {
	source: `${path.resolve(__dirname, argv.source)}/`,
	remote: argv.remote,
	key: argv.key,
	secret: argv.secret,
	bucket: argv.bucket,
  region: argv.region,
  cache: argv.cache
}

SimpleS3Uploader(config)

Call your example-file.js from node, or create a script inside package.json and pass all parameters as string.

node example-file.js bucket="{bucket}" key="{key}" secret="{secret}" remote="{remote}" source="{source}" region="{region}" cache="{cache}"