Skip to content

Instantly share code, notes, and snippets.

@andreybleme
Created April 11, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreybleme/7de5ef9c150e59fc3b98081d036c4a3f to your computer and use it in GitHub Desktop.
Save andreybleme/7de5ef9c150e59fc3b98081d036c4a3f to your computer and use it in GitHub Desktop.
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
const AWS = require('aws-sdk')
const filesystem = require('./filesystem')
function setAwsCredentials(awsCredentials) {
// altera credenciais
}
function createBucket(bucketParams, staticHostParams) {
// cria o bucket
}
function uploadObject(bucket, filePath, data) {
const s3 = new AWS.S3()
s3.putObject({
Bucket: bucket,
Key: filePath,
Body: data,
ACL: 'public-read',
ContentType: filesystem.getMimeType(filePath)
}, function(error, dataS3) {
if (error) {
return console.log('There was an error uploading your file: ', error.message)
}
console.log('Successfully uploaded file: ', filePath)
});
}
function setPoliciesForWebSiteHosting(staticHostParams) {
// altera políticas do bucket
}
module.exports = {
setAwsCredentials,
createBucket,
uploadObject,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment