Created
November 29, 2017 02:14
-
-
Save ramsaylanier/d9c10b10fff1deff8d614562027ca95d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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