How to create new S3 bucket in AWS using nodejs?












1















How to create a new S3 bucket in AWS using nodejs?



I need to upload a large number of the image file on the s3 bucket for ease of using and manage the storage space on the cloud instead of my local server storage.




  • I am working on IoT project which captures the number of images once motion detects any object in their range. So send me the step to follow the configuration of AWS s3 Bucket integration using nodejs.










share|improve this question


















  • 1





    docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

    – Akber Iqbal
    Nov 12 '18 at 7:27
















1















How to create a new S3 bucket in AWS using nodejs?



I need to upload a large number of the image file on the s3 bucket for ease of using and manage the storage space on the cloud instead of my local server storage.




  • I am working on IoT project which captures the number of images once motion detects any object in their range. So send me the step to follow the configuration of AWS s3 Bucket integration using nodejs.










share|improve this question


















  • 1





    docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

    – Akber Iqbal
    Nov 12 '18 at 7:27














1












1








1


1






How to create a new S3 bucket in AWS using nodejs?



I need to upload a large number of the image file on the s3 bucket for ease of using and manage the storage space on the cloud instead of my local server storage.




  • I am working on IoT project which captures the number of images once motion detects any object in their range. So send me the step to follow the configuration of AWS s3 Bucket integration using nodejs.










share|improve this question














How to create a new S3 bucket in AWS using nodejs?



I need to upload a large number of the image file on the s3 bucket for ease of using and manage the storage space on the cloud instead of my local server storage.




  • I am working on IoT project which captures the number of images once motion detects any object in their range. So send me the step to follow the configuration of AWS s3 Bucket integration using nodejs.







node.js amazon-s3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 7:22









MacMac

595




595








  • 1





    docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

    – Akber Iqbal
    Nov 12 '18 at 7:27














  • 1





    docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

    – Akber Iqbal
    Nov 12 '18 at 7:27








1




1





docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

– Akber Iqbal
Nov 12 '18 at 7:27





docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

– Akber Iqbal
Nov 12 '18 at 7:27












3 Answers
3






active

oldest

votes


















1














Use S3 module on your node server and read the documentation.



var s3 = require('s3');

var client = s3.createClient({
maxAsyncS3: 20, // this is the default
s3RetryCount: 3, // this is the default
s3RetryDelay: 1000, // this is the default
multipartUploadThreshold: 20971520, // this is the default (20 MB)
multipartUploadSize: 15728640, // this is the default (15 MB)
s3Options: {
accessKeyId: "your s3 key",
secretAccessKey: "your s3 secret",
// any other options are passed to new AWS.S3()
// See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
},
});





share|improve this answer
























  • Thanks, Manishdan for your kind support. It works for me.

    – Mac
    Nov 13 '18 at 7:28



















0














Try this



 var params = {
Bucket: "examplebucket",
CreateBucketConfiguration: {
LocationConstraint: "eu-west-1"
}
};
s3.createBucket(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});


For more info read this link






share|improve this answer































    0














    Check the document on https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html



    var s3bucket = new AWS.S3({params: {Bucket: 'test_bucket/sub_bucket'}}); 


    will create an extra file. Take out the params in the parentheses. I found out that Amazon's quick start guide example creates an extra file. This way is the correct way to do it.



    // Create a bucket using bound parameters and put something in it.
    var s3bucket = new AWS.S3();
    s3bucket.createBucket(function() {
    var params = {Bucket: 'bucket/sub-bucket', Key: 'file_name1', Body: 'Hello!'};
    s3bucket.putObject(params, function(err, data) {
    if (err) {
    console.log("Error uploading data: ", err);
    } else {
    res.writeHead(200, {'Content-Type':'text/plain'});
    res.write("Successfully uploaded data to bucket/sub-bucket/");
    res.end()
    }
    });
    });





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257488%2fhow-to-create-new-s3-bucket-in-aws-using-nodejs%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Use S3 module on your node server and read the documentation.



      var s3 = require('s3');

      var client = s3.createClient({
      maxAsyncS3: 20, // this is the default
      s3RetryCount: 3, // this is the default
      s3RetryDelay: 1000, // this is the default
      multipartUploadThreshold: 20971520, // this is the default (20 MB)
      multipartUploadSize: 15728640, // this is the default (15 MB)
      s3Options: {
      accessKeyId: "your s3 key",
      secretAccessKey: "your s3 secret",
      // any other options are passed to new AWS.S3()
      // See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
      },
      });





      share|improve this answer
























      • Thanks, Manishdan for your kind support. It works for me.

        – Mac
        Nov 13 '18 at 7:28
















      1














      Use S3 module on your node server and read the documentation.



      var s3 = require('s3');

      var client = s3.createClient({
      maxAsyncS3: 20, // this is the default
      s3RetryCount: 3, // this is the default
      s3RetryDelay: 1000, // this is the default
      multipartUploadThreshold: 20971520, // this is the default (20 MB)
      multipartUploadSize: 15728640, // this is the default (15 MB)
      s3Options: {
      accessKeyId: "your s3 key",
      secretAccessKey: "your s3 secret",
      // any other options are passed to new AWS.S3()
      // See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
      },
      });





      share|improve this answer
























      • Thanks, Manishdan for your kind support. It works for me.

        – Mac
        Nov 13 '18 at 7:28














      1












      1








      1







      Use S3 module on your node server and read the documentation.



      var s3 = require('s3');

      var client = s3.createClient({
      maxAsyncS3: 20, // this is the default
      s3RetryCount: 3, // this is the default
      s3RetryDelay: 1000, // this is the default
      multipartUploadThreshold: 20971520, // this is the default (20 MB)
      multipartUploadSize: 15728640, // this is the default (15 MB)
      s3Options: {
      accessKeyId: "your s3 key",
      secretAccessKey: "your s3 secret",
      // any other options are passed to new AWS.S3()
      // See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
      },
      });





      share|improve this answer













      Use S3 module on your node server and read the documentation.



      var s3 = require('s3');

      var client = s3.createClient({
      maxAsyncS3: 20, // this is the default
      s3RetryCount: 3, // this is the default
      s3RetryDelay: 1000, // this is the default
      multipartUploadThreshold: 20971520, // this is the default (20 MB)
      multipartUploadSize: 15728640, // this is the default (15 MB)
      s3Options: {
      accessKeyId: "your s3 key",
      secretAccessKey: "your s3 secret",
      // any other options are passed to new AWS.S3()
      // See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
      },
      });






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 12 '18 at 7:27









      Gaurav joshiGaurav joshi

      1,327921




      1,327921













      • Thanks, Manishdan for your kind support. It works for me.

        – Mac
        Nov 13 '18 at 7:28



















      • Thanks, Manishdan for your kind support. It works for me.

        – Mac
        Nov 13 '18 at 7:28

















      Thanks, Manishdan for your kind support. It works for me.

      – Mac
      Nov 13 '18 at 7:28





      Thanks, Manishdan for your kind support. It works for me.

      – Mac
      Nov 13 '18 at 7:28













      0














      Try this



       var params = {
      Bucket: "examplebucket",
      CreateBucketConfiguration: {
      LocationConstraint: "eu-west-1"
      }
      };
      s3.createBucket(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else console.log(data); // successful response
      });


      For more info read this link






      share|improve this answer




























        0














        Try this



         var params = {
        Bucket: "examplebucket",
        CreateBucketConfiguration: {
        LocationConstraint: "eu-west-1"
        }
        };
        s3.createBucket(params, function(err, data) {
        if (err) console.log(err, err.stack); // an error occurred
        else console.log(data); // successful response
        });


        For more info read this link






        share|improve this answer


























          0












          0








          0







          Try this



           var params = {
          Bucket: "examplebucket",
          CreateBucketConfiguration: {
          LocationConstraint: "eu-west-1"
          }
          };
          s3.createBucket(params, function(err, data) {
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          });


          For more info read this link






          share|improve this answer













          Try this



           var params = {
          Bucket: "examplebucket",
          CreateBucketConfiguration: {
          LocationConstraint: "eu-west-1"
          }
          };
          s3.createBucket(params, function(err, data) {
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          });


          For more info read this link







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 7:26









          Sachin ShahSachin Shah

          1,6241415




          1,6241415























              0














              Check the document on https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html



              var s3bucket = new AWS.S3({params: {Bucket: 'test_bucket/sub_bucket'}}); 


              will create an extra file. Take out the params in the parentheses. I found out that Amazon's quick start guide example creates an extra file. This way is the correct way to do it.



              // Create a bucket using bound parameters and put something in it.
              var s3bucket = new AWS.S3();
              s3bucket.createBucket(function() {
              var params = {Bucket: 'bucket/sub-bucket', Key: 'file_name1', Body: 'Hello!'};
              s3bucket.putObject(params, function(err, data) {
              if (err) {
              console.log("Error uploading data: ", err);
              } else {
              res.writeHead(200, {'Content-Type':'text/plain'});
              res.write("Successfully uploaded data to bucket/sub-bucket/");
              res.end()
              }
              });
              });





              share|improve this answer




























                0














                Check the document on https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html



                var s3bucket = new AWS.S3({params: {Bucket: 'test_bucket/sub_bucket'}}); 


                will create an extra file. Take out the params in the parentheses. I found out that Amazon's quick start guide example creates an extra file. This way is the correct way to do it.



                // Create a bucket using bound parameters and put something in it.
                var s3bucket = new AWS.S3();
                s3bucket.createBucket(function() {
                var params = {Bucket: 'bucket/sub-bucket', Key: 'file_name1', Body: 'Hello!'};
                s3bucket.putObject(params, function(err, data) {
                if (err) {
                console.log("Error uploading data: ", err);
                } else {
                res.writeHead(200, {'Content-Type':'text/plain'});
                res.write("Successfully uploaded data to bucket/sub-bucket/");
                res.end()
                }
                });
                });





                share|improve this answer


























                  0












                  0








                  0







                  Check the document on https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html



                  var s3bucket = new AWS.S3({params: {Bucket: 'test_bucket/sub_bucket'}}); 


                  will create an extra file. Take out the params in the parentheses. I found out that Amazon's quick start guide example creates an extra file. This way is the correct way to do it.



                  // Create a bucket using bound parameters and put something in it.
                  var s3bucket = new AWS.S3();
                  s3bucket.createBucket(function() {
                  var params = {Bucket: 'bucket/sub-bucket', Key: 'file_name1', Body: 'Hello!'};
                  s3bucket.putObject(params, function(err, data) {
                  if (err) {
                  console.log("Error uploading data: ", err);
                  } else {
                  res.writeHead(200, {'Content-Type':'text/plain'});
                  res.write("Successfully uploaded data to bucket/sub-bucket/");
                  res.end()
                  }
                  });
                  });





                  share|improve this answer













                  Check the document on https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html



                  var s3bucket = new AWS.S3({params: {Bucket: 'test_bucket/sub_bucket'}}); 


                  will create an extra file. Take out the params in the parentheses. I found out that Amazon's quick start guide example creates an extra file. This way is the correct way to do it.



                  // Create a bucket using bound parameters and put something in it.
                  var s3bucket = new AWS.S3();
                  s3bucket.createBucket(function() {
                  var params = {Bucket: 'bucket/sub-bucket', Key: 'file_name1', Body: 'Hello!'};
                  s3bucket.putObject(params, function(err, data) {
                  if (err) {
                  console.log("Error uploading data: ", err);
                  } else {
                  res.writeHead(200, {'Content-Type':'text/plain'});
                  res.write("Successfully uploaded data to bucket/sub-bucket/");
                  res.end()
                  }
                  });
                  });






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 6:04









                  MANISHDAN LANGAMANISHDAN LANGA

                  1,36042342




                  1,36042342






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257488%2fhow-to-create-new-s3-bucket-in-aws-using-nodejs%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown