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

xizhi-uploads3

v1.0.5

Published

A package for uploading assets to S3 and refreshing CloudFront

Downloads

9

Readme

xizhi-uploads3

A simple utility to upload local files to Amazon S3. Configure your S3 keys and bucket to complete the upload.

Features

  • Upload files to Amazon S3
  • Easy configuration of S3 keys and bucket
  • Lightweight and straightforward to use

Installation

To install the package, use your preferred package manager:

npm install xizhi-uploads3
# or
pnpm add xizhi-uploads3

Configuration

Before using the package, you need to configure your S3 credentials and bucket information.

How to Use

Here is a basic example of how to use the xizhi-uploads3 package to upload a local file to S3:

import { uploadFile } from 'xizhi-uploads3';

const s3Config = {
  accessKeyId: 'YOUR_ACCESS_KEY_ID',
  secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
  region: 'YOUR_S3_REGION',
  bucketName: 'YOUR_BUCKET_NAME',
};

const localFilePath = './path/to/your/local/file.txt'; // Use relative path, not path alias
const s3Key = 'desired/path/in/s3/file.txt';

uploadFile(s3Config, localFilePath, s3Key)
  .then((response) => {
    console.log('File uploaded successfully:', response);
  })
  .catch((error) => {
    console.error('Error uploading file:', error);
  });

Configuration Object

  • accessKeyId: Your AWS Access Key ID.
  • secretAccessKey: Your AWS Secret Access Key.
  • region: The AWS region where your S3 bucket is located.
  • bucketName: The name of your S3 bucket.

Parameters

  • localFilePath: The relative path to the local file you want to upload. Do not use path aliases; use relative paths instead.
  • s3Key: The desired key (path) in the S3 bucket where the file will be uploaded.

Notes

  • Ensure that your AWS credentials have the necessary permissions to upload files to the specified S3 bucket.
  • Always use relative paths for the localFilePath to avoid issues with path resolution.

Example

import { uploadFile } from 'uploadS3';

const s3Config = {
  accessKeyId: 'YOUR_ACCESS_KEY_ID',
  secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
  region: 'YOUR_S3_REGION',
  bucketName: 'YOUR_BUCKET_NAME',
};

const localFilePath = './uploads/myFile.txt'; // Use relative path
const s3Key = 'uploads/myFile.txt';

uploadFile(s3Config, localFilePath, s3Key)
  .then((response) => {
    console.log('File uploaded successfully:', response);
  })
  .catch((error) => {
    console.error('Error uploading file:', error);
  });

License

This project is licensed under the MIT License. See the LICENSE file for details.


This should provide a comprehensive guide for users on how to configure and use your package to upload files to S3.