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-s3-file-upload

v1.0.0

Published

image and document upload

Downloads

3

Readme

aws-s3-file-upload

This package allows you to easily upload images and files to Amazon S3 storage and obtain the corresponding links for the uploaded content.

Overview

This package provides functions to simplify the process of uploading images and other files to AWS S3 storage and obtaining the corresponding file links. It supports both image upload from a file and base64-encoded strings.

Installation

You can install this package using npm:

npm install aws-s3-file-upload

Usage

Uploading Images and Files

To upload images to AWS S3, you can use the awsS3FormDataUpload function. Here's an example of how to use it:

const imageUpload = require('aws-s3-file-upload');

const data = {
    accesskey: 'your_access_key',
    secretkey: 'your_secret_key',
    bucketname: 'your_bucket_name/your_bucket_folder_name',
    image: your_files
};

const response = imageUpload.awsS3FormDataUpload(data.accesskey, data.secretkey, data.bucketname, data.image);

console.log(response);

Uploading Base64-Encoded Files For AWS S3, you can also upload base64-encoded strings using the awsS3Base64Upload function. Here's an example:

const imageUpload = require('aws-s3-file-upload');

const data = {
    accesskey: 'your_access_key',
    secretkey: 'your_secret_key',
    bucketname: 'your_bucket_name/your_bucket_folder_name',
    base64String: ['base64_encoded_string_1', 'base64_encoded_string_2'],
    contentType: 'image', // or 'document', 'video', etc.
    contentFormat: 'png' // or 'jpeg', 'pdf', 'mp4', etc.
};

const response = imageUpload.awsS3Base64Upload(data.accesskey, data.secretkey, data.bucketname, data.base64String, data.contentType, data.contentFormat);

console.log(response);

Deleting Uploaded Files You can also delete uploaded files using the deleteS3File function. Here's an example:

const imageUpload = require('aws-s3-file-upload');

const response = imageUpload.deleteS3File('your_access_key', 'your_secret_key', 'your_bucket_name/your_bucket_folder_name', 'https://your_s3_link/file_key');

console.log(response);

Response Format The response from both upload functions will be an object with the following structure:

{
    "success": true,
    "message": "Successfully uploaded",
    "data": [
        {
            "ETag": "\"file_etag\"",
            "ServerSideEncryption": "AES256",
            "Location": "https://your_bucket_name.s3.amazonaws.com/your_file_key",
            "key": "your_bucket_folder_name/your_file_key",
            "Key": "your_bucket_folder_name/your_file_key",
            "Bucket": "your_bucket_name"
        }
    ]
}

Response Format: The response from deleted functions will be an object with the following structure:

{
    "success": true,
    "message": "Successfully deleted",
    
}

Dependencies This package relies on AWS SDK for JavaScript in Node.js to interact with AWS S3.

Note Ensure that you have appropriate permissions set up on your AWS account to perform S3 operations.

Please make sure to replace placeholders like your_access_key, your_secret_key, your_bucket_name, your_bucket_folder_name, base64_encoded_image_string, and others with actual values as needed.

Feel free to customize the README further to include any additional information, examples, or explanations that you think would be helpful for users of your package.