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

aws-sharp

v1.0.6

Published

This contains a reference to the aws-sdk and sharp module. It is a valid use case to use

Downloads

16

Readme

Installation

npm install aws-sharp -s

Features

  • Upload Images to AWS S3 with compressed size without loosing Quality.
  • It should supported to JPG,PNG,JPEG WEBP.
  • Forced to save image into required format.
  • Provide Image Quality Option While compressing.

Synopsis

Create a AWSClient

var aws_sharp = require('aws-sharp');

var AWSClient = aws_sharp.createCredentials({
  s3Credentials: {
    accessKeyId: "your s3 key",
    secretAccessKey: "your s3 secret"
  },
});

Upload a Image to S3

const options : {
    toFile:"string" // force to convert into required image format,
    quality:Number  // provide quality while compressimage, max allowed to 80
}
var params = {
    "Base64 Image",
    "Bucket Name",
    options
  },
};

AWSClient.uploadBase64ImageWithCompress(params).then(s3_path=>{
    console.log(s3_path)
}).catch(error=>{
    console.log(error)
})

API Documentation

This contains a reference to the aws-sdk and sharp module. It is a valid use case to use both this module and the lower level aws-sdk module in tandem.

aws_sharp.createCredentials(options)

Creates an S3 client.

options:

  • s3Credentials - optional, an instance of AWS.S3. Leave blank if you set aws-cli configuration .

aws_sharp.uploadBase64ImageWithCompress(params)

See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property

params:

  • base64Image: base64 image string passes as argument.
  • bucketName: bucket name to the save file on particualr s3 bucket.
  • options : (optional)toFile: Force to save to particular format ['png','jpeg','jpg','webp'] default set to webp.
  • quality parameter in sharp, set qaulity while compress default set to 20 Max allowed to 80

Examples

Upload Base64 Image to S3 with compress size without loose quality

var AWSClient = require('aws-sharp').createCredentials({ /* AWS KEYS */ });
AWSClient.uploadBase64ImageWithCompress(params).then(s3_path=>{
   console.log('S3_Path',s3_path)
}).catch(error=>{
    console.log("Error", error)
})

Testing

create .env file in root folder and set following keys.

AWS_S3_KEY_ID=<valid_s3_key> AWS_S3_SECRET=<valid_s3_secret> AWS_S3_BUCKET=<valid_s3_bucket> npm test