Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs s3 read

# This function for delete file from s3 bucket
const s3delete = function (params) {
    return new Promise((resolve, reject) => {
        s3.createBucket({
            Bucket: BUCKET_NAME        /* Put your bucket name */
        }, function () {
            s3.deleteObject(params, function (err, data) {
                if (err) console.log(err);
                else
                    console.log(
                        "Successfully deleted file from bucket";
                    );
                console.log(data);
            });
        });
    });
};
Comment

nodejs s3 read

# This function for read/download file from s3 bucket
const s3download = function (params) {
    return new Promise((resolve, reject) => {
        s3.createBucket({
            Bucket: BUCKET_NAME        /* Put your bucket name */
        }, function () {
            s3.getObject(params, function (err, data) {
                if (err) {
                    reject(err);
                } else {
                    console.log("Successfully dowloaded data from  bucket");
                    resolve(data);
                }
            });
        });
    });
}
Comment

nodejs s3 read

#This function for upload file to s3 bucket
const s3upload = function (params) {
    return new Promise((resolve, reject) => {
        s3.createBucket({
            Bucket: BUCKET_NAME        /* Put your bucket name */
        }, function () {
            s3.putObject(params, function (err, data) {
                if (err) {
                    reject(err)
                } else {
                     console.log("Successfully uploaded data to bucket");
                    resolve(data);
                }
            });
        });
    });
}
Comment

nodejs s3 read

const params = {
  Bucket: BUCKET_NAME,  /* required */        # Put your bucket name
  Key: fileName         /* required */        # Put your file name
};
Comment

nodejs s3 read

$ npm install aws-sdk
Comment

nodejs s3 read

const s3 = new AWS.S3({
  accessKeyId: IAM_USER_KEY,  /* required */ # Put your iam user key
  secretAccessKey: IAM_USER_SECRET, /* required */  # Put your iam user secret key
  Bucket: BUCKET_NAME     /* required */     # Put your bucket name
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: time zone npm in next js 
Javascript :: find component inside tree with enzyme shallow wrapper 
Javascript :: initializing a property asynchronously 2 
Javascript :: unban command discord.js v12 
Javascript :: which element occours when a DOM element recieve the coursor 
Javascript :: erpnext date difference client script 
Javascript :: pass data from parent to child component angular 8 
Javascript :: react proxy to flask server 
Javascript :: select elm inside a specific id in js 
Javascript :: javascript class prototype 
Javascript :: listen to keyboard close event in js 
Javascript :: clear input field javascript 
Javascript :: prop callback that changes parent state result in infinite render react js 
Javascript :: jstree get not disabled nodes 
Javascript :: handle stream javascript 
Javascript :: exitBeforeEnter not working 
Javascript :: javascript nested destructuring 
Javascript :: child to perent data transfer in angular 
Javascript :: decrypt javascript code 
Javascript :: JavaScript code to convert amount in words 
Javascript :: date calendar show only icon click 
Javascript :: styling font awesome icons next js 
Javascript :: how to add element in array in angular 
Javascript :: draft save using jquery 
Javascript :: Class Has a Constructor Function 
Javascript :: react.js form 
Javascript :: Backbone Initialize vs Render 
Javascript :: get data from json key with special character 
Javascript :: FirebaseError: Unknown field filter op. 
Javascript :: react Dark/Light mode 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =