Skip to content

Instantly share code, notes, and snippets.

@ramsaylanier
Created November 29, 2017 02:14
Show Gist options
  • Select an option

  • Save ramsaylanier/d9c10b10fff1deff8d614562027ca95d to your computer and use it in GitHub Desktop.

Select an option

Save ramsaylanier/d9c10b10fff1deff8d614562027ca95d to your computer and use it in GitHub Desktop.
import {config, S3} from 'aws-sdk'
import {aws} from 'config'
import {map} from 'lodash'
const {region, accessKeyId, secretAccessKey, uploadBucket} = aws
config.update({
region: region,
credentials: {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey
}
})
config.setPromisesDependency(Promise)
export const s3UploadBucket = new S3({
apiVersion: '2006-03-01',
params: {
Bucket: uploadBucket
}
})
export const uploadFiles = (files) => {
return Promise.all(
map(files, file => {
return s3UploadBucket.putObject({
Key: file.name,
Body: file
}).promise()
})
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment