UNPKG

asksuite-core

Version:
28 lines (23 loc) 603 B
const AWS = require('aws-sdk'); class AWSS3Caller { constructor(awsConfig) { AWS.config.update(awsConfig); } async getObject(bucket, key) { const s3 = new AWS.S3(); const getParams = { Bucket: bucket, Key: key, }; return new Promise((resolve, reject) => { s3.getObject(getParams) .promise() .then(function(data) { const body = data.Body.toString('utf-8'); resolve(JSON.parse(body)); // Use the encoding necessary }) .catch(reject); }); } } module.exports = AWSS3Caller;