Created
April 11, 2019 19:34
-
-
Save andreybleme/7de5ef9c150e59fc3b98081d036c4a3f to your computer and use it in GitHub Desktop.
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
This file contains 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
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