Skip to content

Instantly share code, notes, and snippets.

@ppshein
Last active March 27, 2020 03:02
Show Gist options
  • Select an option

  • Save ppshein/a3975e90ed9089d5a1d11d4ba59e35d7 to your computer and use it in GitHub Desktop.

Select an option

Save ppshein/a3975e90ed9089d5a1d11d4ba59e35d7 to your computer and use it in GitHub Desktop.

Revisions

  1. ppshein revised this gist Mar 27, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aws-s3-upload.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ AWS.config.update({

    const params = {
    Bucket: `mobile-ayaplus-backend-dev`,
    Key: `tmp/mytestimage.png`,
    Key: `ayapay-merchant/mytestimage.png`,
    Body: fs.createReadStream(`./mytestimage.png`),
    ContentType: 'image/png',
    StorageClass: 'STANDARD_IA'
  2. ppshein revised this gist Mar 27, 2020. No changes.
  3. ppshein renamed this gist Mar 27, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. ppshein created this gist Mar 18, 2020.
    25 changes: 25 additions & 0 deletions upload.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    const AWS = require("aws-sdk");
    const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
    const fs = require("fs");

    AWS.config.update({
    accessKeyId: "",
    secretAccessKey: "",
    region: "ap-southeast-1",
    Bucket: "mobile-ayaplus-backend-dev",
    })

    const params = {
    Bucket: `mobile-ayaplus-backend-dev`,
    Key: `tmp/mytestimage.png`,
    Body: fs.createReadStream(`./mytestimage.png`),
    ContentType: 'image/png',
    StorageClass: 'STANDARD_IA'
    };

    s3.upload(params, function(err, result) {
    if (err) {
    throw err;
    }
    console.log(`File uploaded successfully. ${JSON.stringify(result)}`);
    });