How to use the aws-sdk.Endpoint function in aws-sdk

To help you get started, we’ve selected a few aws-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badunk / multer-s3 / test / integration / express.spec.js View on Github external
var upload = multer({storage: multerS3({
  bucket: 'some-bucket',
  secretAccessKey: 'some secret',
  accessKeyId: 'some key',
  region: 'us-east-1',
  s3ForcePathStyle: true,
  endpoint: new AWS.Endpoint('http://localhost:4568')
})})

var uploadAuto = multer({storage: multerS3({
  bucket: 'some-bucket',
  secretAccessKey: 'some secret',
  accessKeyId: 'some key',
  region: 'us-east-1',
  s3ForcePathStyle: true,
  endpoint: new AWS.Endpoint('http://localhost:4568'),
  contentType: multerS3.AUTO_CONTENT_TYPE
})})

var uploadCustomKey = multer({storage: multerS3({
  bucket: 'some-bucket',
  secretAccessKey: 'some secret',
  accessKeyId: 'some key',
  region: 'us-east-1',
  s3ForcePathStyle: true,
  endpoint: new AWS.Endpoint('http://localhost:4568'),
  key: function (req, file, cb) {
    cb(null, 'key-name')
  }
})})

// express setup
github webgme / webgme / src / server / middleware / blob / BlobS3Backend.js View on Github external
this.awsConfig = gmeConfig.blob.s3;
    // NOTE: development mode
    // install https://github.com/jubos/fake-s3
    // make sure you apply my patch: https://github.com/jubos/fake-s3/issues/53
    // build and install it
    // Alternatively use https://github.com/jamhall/s3rver for nodejs
    // Add to your /etc/hosts (on windows C:\Windows\System32\drivers\etc\hosts and the below are reversed)
    // 127.0.0.1 wg-content.localhost
    // 127.0.0.1 wg-metadata.localhost
    // 127.0.0.1 wg-temp.localhost

    AWS.config.update(this.awsConfig);
    this.s3 = new AWS.S3();

    // also tried creating an `EndPoint`:
    this.s3.endpoint = new AWS.Endpoint(this.awsConfig.endpoint);

    // Uncomment to create buckets at start-up when developing
    // [this.tempBucket, this.contentBucket, this.metadataBucket].forEach( bucket => {
    //     this.s3.createBucket({
    //         Bucket: bucket
    //     }, function(err, data) {
    //         if (err) {
    //             console.log(err, err.stack);
    //         } else {
    //             console.log(data);
    //         }
    //     });
    // });
};
github sitespeedio / sitespeed.io / lib / plugins / s3 / index.js View on Github external
function createS3(s3Options) {
  let endpoint = s3Options.endpoint || 's3.amazonaws.com';
  const options = {
    endpoint: new AWS.Endpoint(endpoint),
    accessKeyId: s3Options.key,
    secretAccessKey: s3Options.secret,
    signatureVersion: 'v4'
  };
  // You can also set some extra options see
  // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
  Object.assign(options, s3Options.options);
  return new AWS.S3(options);
}
github joona / aws-es-curl / index.js View on Github external
input = yield readStdin();
      }

      if(!maybeUrl || (maybeUrl && maybeUrl == 'help') || options.help || options.h) {
        console.log('Usage: aws-es-curl [options] ');
        console.log();
        console.log('Options:');
        console.log("\t-X, --method \tHTTP method \t(Default: GET)");
        console.log("\t--profile \tAWS profile \t(Default: default)");
        console.log("\t--region \tAWS region \t(Default: eu-west-1)");
        process.exit(1);
      }

      if(maybeUrl && maybeUrl.indexOf('http') === 0) {
        var uri = url.parse(maybeUrl);
        var endpoint = new AWS.Endpoint(uri.host);
        var response = yield execute(endpoint, region, uri.path, method, input);
        process.stdout.write(response + "\n");
      }
    })
    .then(res => {
github CleverCloud / clever-tools / scripts / job-publish-cellar.js View on Github external
function cellar ({ accessKeyId, secretAccessKey, host, bucket }) {

  AWS.config.update({ accessKeyId, secretAccessKey });
  const s3 = new AWS.S3({
    endpoint: new AWS.Endpoint(host),
    signatureVersion: 'v4',
  });

  return async function (filepath, remoteFilepath = filepath) {
    const Body = await fs.readFile(filepath);
    console.log(`Uploading file on Cellar ...`);
    console.log(`\tfile ${filepath}`);
    console.log(`\tto ${remoteFilepath}`);
    return new Promise((resolve, reject) => {
      const params = { ACL: 'public-read', Body, Bucket: bucket, Key: remoteFilepath };
      return s3.putObject(params, (err) => err ? reject(err) : resolve());
    }).then(() => console.log(`\tDONE!`));
  };
}
github ar90n / serverless-s3-local / example / webpack_support / src / hooks.js View on Github external
const webhook = (event, context, callback) => {
  const S3 = new AWS.S3({
    s3ForcePathStyle: true,
    endpoint: new AWS.Endpoint('http://localhost:8000'),
    accessKeyId: 'S3RVER',
    secretAccessKey: 'S3RVER',
  });
  S3.putObject({
    Bucket: 'local-bucket',
    Key: '1234',
    Body: new Buffer('abcd'),
  }, () => {});

  callback(null, 'ok');
};
github connect-foundation / 2019-03 / api-server / utils / upload.js View on Github external
const AWS = require('aws-sdk');

const endpoint = new AWS.Endpoint('https://kr.object.ncloudstorage.com');
const region = 'kr-standard';
const accessKey = `${process.env.ACCESS_KEY}`;
const secretKey = `${process.env.SECRET_KEY}`;

AWS.config.update({
  accessKeyId: accessKey,
  secretAccessKey: secretKey,
});

const s3 = new AWS.S3({
  endpoint,
  region,
});

const uploadImageFileToS3 = async (file, dir) => {
  try {
github lifeomic / lambda-tools / src / utils / awsUtils.js View on Github external
function buildConfigFromConnection (connection) {
  return {
    credentials: new AWS.Credentials(connection.accessKey, connection.secretAccessKey),
    endpoint: new AWS.Endpoint(connection.url),
    region: connection.region,
    maxRetries: 10
  };
}
github looker / lookerbot / src / stores / amazon_s3_store.ts View on Github external
const region = process.env.SLACKBOT_S3_BUCKET_REGION
    const domain = region && (region !== "us-east-1") ?
      `s3-${process.env.SLACKBOT_S3_BUCKET_REGION}.amazonaws.com`
    :
      "s3.amazonaws.com"

    const params = {
      ACL: "public-read",
      Body: buffer,
      Bucket: process.env.SLACKBOT_S3_BUCKET,
      ContentType: "image/png",
      Key: key,
    }

    const s3 = new AWS.S3({
      endpoint: new AWS.Endpoint(domain) as any,
    })

    return new Promise((resolve, reject) => {
      s3.putObject(params, (err, data) => {
        if (err) {
          reject(`S3 Error: ${err.message}`)
        } else {
          resolve(`https://${domain}/${params.Bucket}/${key}`)
        }
      })
    })

  }
}
github legalthings / lambda-pdf-thumbnail / lambda-pdf-thumbnail.spec.js View on Github external
.run(function(err) {
        if (err) {
          callback(err);
          return;
        }
        var config = {
          s3ForcePathStyle: true,
          accessKeyId: 'ACCESS_KEY_ID',
          secretAccessKey: 'SECRET_ACCESS_KEY',
          endpoint: new AWS.Endpoint('http://localhost:10001')
        };

        var s3 = new AWS.S3(config);
        callback(null, s3);
      });
  }