aws-s3-upload-ash

Open Source Module to Upload your Media and files into AWS S3 Bucket directly from Front-end
18,725 6
Install
npm install aws-s3-upload-ash
Latest Version:1.2.0
License:MIT
Last Updated:Jun 5, 2024
Links: GitHub  ·  npm
Maintainer: ismaelnascimento

aws-s3-upload-ash

Open Source Module to Upload your Media and files into AWS S3 Bucket directly from Front-end.
AWSS3UploadAsh - A Javascript Library for AWS S3 File Upload

NPM

https://www.npmjs.com/package/aws-s3-upload-ash

Donate

http://bit.ly/doeismaelnascimento

How to use(youtube)

How to get

Using NPM

npm install aws-s3-upload-ash

Using Yarn

yarn add aws-s3-upload-ash

Examples Uploading a file

React using Next.js

Angular 12

Vue

Deleting an existing file into directory in your bucket public

In this case the file that we want to delete is in the folder 'photos'

import AWSS3UploadAsh from 'aws-s3-upload-ash';


const config = {
    bucketName: 'bucketName',
    dirName: 'media',
    region: 'us-east-1',
    accessKeyId: process.env.accessKeyId,
    secretAccessKey: process.env.secretAccessKey,
    s3Url: 'https://bucketName.s3.amazonaws.com/'
}

const S3CustomClient = new AWSS3UploadAsh(config);

const newFileNameWithExtesion = 'fileName.extesion';

S3CustomClient
    .deleteFile(newFileNameWithExtesion)
    .then(response => console.log(response))
    .catch(err => console.error(err))

  /**
   * {
   *   Response: {
   *      ok: true,
   *      status: 204,
   *      message: 'File deleted',
   *      fileName: 'media/fileName.extesion';
   *   }
   * }
   */
});

Deleting an existing file without directory in your bucket public

import AWSS3UploadAsh from 'aws-s3-upload-ash';


const config = {
    bucketName: 'bucketName',
    region: 'us-east-1',
    accessKeyId: process.env.accessKeyId,
    secretAccessKey: process.env.secretAccessKey,
    s3Url: 'https://bucketName.s3.amazonaws.com/'
}

const S3CustomClient = new AWSS3UploadAsh(config);

const newFileNameWithExtesion = 'fileName.extesion';

S3CustomClient
    .deleteFile(newFileNameWithExtesion)
    .then(response => console.log(response))
    .catch(err => console.error(err))

  /**
   * {
   *   Response: {
   *      ok: true,
   *      status: 204,
   *      message: 'File deleted',
   *      fileName: 'fileName.extesion';
   *   }
   * }
   */
});

Important

  1. If you bucket is public use only this parameters: file, contentType, newFileNameWithExtesion see the example above
  2. If you bucket is private(with Objects can be public) use presignedURL parameter (recommended)

AWS S3 Links

License

MIT

Related Packages

aws-s3

S3Client - A Javascript Library for AWS S3 File Upload

104,930 115
aws-s3-pro

S3Client - A Javascript Library for AWS S3 File Upload

3,923 115
s3-spa-upload

Upload a single page application to S3 with the right content-type and cache-con...

549,106 28
aws-spa

A no-brainer script to deploy a single page app on AWS

8,157 42
file-uploader-component

A reactjs and vuejs component of file uploader.

17,744 12

Version History

Version Released License
1.2.0 MIT
1.1.7 MIT
1.1.6 MIT
1.1.5 MIT
1.1.4 MIT