Skip to content

Instantly share code, notes, and snippets.

@jpfong
Last active December 2, 2017 19:56
Show Gist options
  • Select an option

  • Save jpfong/bc11159e31edb3380551d4ab778f9a6b to your computer and use it in GitHub Desktop.

Select an option

Save jpfong/bc11159e31edb3380551d4ab778f9a6b to your computer and use it in GitHub Desktop.

Revisions

  1. jpfong revised this gist Dec 2, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions put-object-aws
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@ const aws = require('aws-sdk');
    const s3 = new aws.S3();

    var params = {
    Bucket: process.env.S3_BUCKET_NAME,
    Key: 'file.png', // if in a directory, the key would be: 'directory_name/file_name.ext'
    Bucket: 'bucket_name',
    Key: 'file.png', // if you want to put in a directory, the key would be: 'directory_name/file_name.ext'
    ACL: 'public-read', // to allow to access the file
    Body: data // the data of the file
    };
  2. jpfong created this gist Dec 2, 2017.
    16 changes: 16 additions & 0 deletions put-object-aws
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    const aws = require('aws-sdk');
    const s3 = new aws.S3();

    var params = {
    Bucket: process.env.S3_BUCKET_NAME,
    Key: 'file.png', // if in a directory, the key would be: 'directory_name/file_name.ext'
    ACL: 'public-read', // to allow to access the file
    Body: data // the data of the file
    };
    s3.putObject(params, (err, data) => {
    if (err) {
    console.error('Error uploading image: ', err);
    } else {
    console.log(data);
    }
    });