View on GitHub

NodeJS Notes

Compilation of NodeJS Notes

S3 NodeJS Operations

Visitors

Important Note: All methods are simplified versions of the actual code

For simplicity I have compiled all aws s3 operations functions into methods that are simplified versions of the actual code. This way you can use/perform basic operations directly. But if required to perform complex operations, I have also provided the complete parameters body in comment in every function of s3.js file. Feel free to modify them as per your requirement.

Make sure to update the region in aws-s3.js file, currently it is set to mumbai region.

Steps to get started

Step 1: Import S3 Module

// Import the module from s3.js
var s3op = require('./aws-s3');

Step 2: Call your method (Important: Use await for all calls)

var bucketName = "test-bucket-delete-later-22"
await s3op.createBucket(bucketName);

Functions Descriptions

Function - createBucket, putObject, deleteObject, deleteObjects and deleteBucket return true if everything goes well, else they return false if any error occurs. If required you can also put a check on function as shown in example below:

var flag = await s3op.deleteObject(bucketName, "test3.txt");
if(flag) {
    statusMessage = "File deleted!"
} else {
    statusMessage = "File not deleted!"
}

Note to Self

Reference

Visitors