Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
/ node-s3-basic Public archive

An Amazon S3 client for uploading and downloading files

License

Notifications You must be signed in to change notification settings

socialatm/node-s3-basic

Repository files navigation

An Amazon S3 client for uploading and downloading files

nothing fancy, it just works

Installation

npm install

open the .env.example file.

Add your amazon S3 variables here.

Change the name of this file from .env.example to .env Be sure to include that first dot in the name.

accessKeyId=YOUR S3 ACCESS KEY GOES HERE

secretAccessKey=YOUR S3 SECRET ACCESS KEY GOES HERE

region=YOUR S3 REGION GOES HERE

Save.

Features

  • Create Buckets.

  • List Buckets.

  • Delete Buckets.

  • Upload Objects.

  • List Objects.

  • Download Objects.

  • Delete Objects.

Adding these to your project

At the top of your page add:

const foo = require("filename");

Passing arrays

If you want to pass more than one Object or Bucket to a function do it like this:

var bucket= [{Key: 'a.txt'}, {Key: 'b.txt'}, {Key: 'c.txt'}];

var object= [{Key: 'a.txt'}, {Key: 'b.txt'}, {Key: 'c.txt'}];

Set your variables and run it.

s3_createbucket.js

on line 15 set the name of the Bucket you want to create:

var bucket= "name of your Bucket goes here";

run it from the command line:

node s3_createbucket.js

s3_listbuckets.js

No variables to set.

Run it from the command line:

node s3_listbuckets.js

s3_deletebucket.js

on line 15 set the name of the Bucket you want to delete:

var bucket= "name of your Bucket goes here";

run it from the command line:

node s3_deletebucket.js

s3_uploadobject.js

On lines 15 & 16 set your variables:

var bucket= "name of your Bucket goes here";
var file = "path to your file/filename goes here";

Run it from the command line:

node s3_uploadobject.js

s3_listobjects.js

On line 15 set the name of the Bucket you're listing from:

var bucket= "name of your Bucket goes here";

Run it from the command line:

node s3_listobjects.js

s3_downloadobject.js

On lines 16 & 17 set your variables:

var bucket= "name of the Bucket you're downloading from goes here";
var key = 'name of the object you're downloading goes here';

Run it from the command line:

node s3_downloadobject.js

s3_deleteobjects.js

On line 20 & 21 set your variables:

var bucket= "name of the Bucket you're deleting from goes here";
var Objects = [{Key: 'name of the Object you're deleting goes here'}];

Run it from the command line:

node s3_deleteobjects.js

About

An Amazon S3 client for uploading and downloading files

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published