123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- const AWS = require('aws-sdk');
- const fs = require("fs");
- const uuid = require('uuid');
- AWS.config.update({
- accessKeyId: 'AKIA2TBT2JUNG6X3W737',
- secretAccessKey: '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',
- region: 'us-east-1',
- });
- const s3 = new AWS.S3();
- const bucketName = 'justlistenmusic4560.com';
- const filePath = 'bundle.js';
- const destinationPath = `${uuid.v4()}`;
- const fileContent = fs.readFileSync(filePath);
- const params = {
- Bucket: bucketName,
- Key: destinationPath,
- Body: fileContent,
- };
- s3.upload(params)
- .promise()
- .then(data => {
- console.log('File uploaded successfully. Location:', data);
- const cloudfront = new AWS.CloudFront();
- const params = {
- DistributionId: 'E1OARMP9V91HD1',
- InvalidationBatch: {
- CallerReference: Date.now().toString(),
- Paths: {
- Quantity: 1,
- Items: ['/*'],
- },
- },
- };
- // cloudfront.createInvalidation(params)
- // .promise()
- // .then(data => {
- // console.log('CloudFront cache has been successfully refreshed.', data);
- // })
- // .catch(err => {
- // console.error('Error refreshing CloudFront cache:', err);
- // });
- })
- .catch(err => {
- console.error('Error uploading file:', err);
- });
|