1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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:', Object.assign({
- "Location2": data.Location.replace("https://s3.amazonaws.com/justlistenmusic4560.com", "https://d3crpuooyqht8f.cloudfront.net")
- }, 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);
- });
|