0

我想使节点 js 中 s3 存储桶中的文件夹(和子文件夹)无效。这是我目前正在使用的脚本:

var clearCloudfrontCache = function() {
    console.log("clearCloudfrontCache function started");
    var cloudfront = new AWS.CloudFront();
    var currentTimeStamp = new Date().getTime();
    var params = {
        DistributionId: distribution_ID,
        InvalidationBatch: {
          CallerReference: currentTimeStamp.toString(),
          Paths: {
            Quantity: NumberOfFiles,
            Items: FormerFiles
          }
      }
    };
    cloudfront.createInvalidation(params, function(err, data) {
      if (err) {
        console.log("Error came while cloudfront cache removal",err);
      }
      else {
        console.log("Cloudfront cache removed",data);
      }
    });

这就是我得到的答案:

Error came while cloudfront cache removal InvalidArgument: Your request contains one or more invalid invalidation paths.
    at Request.extractError (/app/node_modules/aws-sdk/lib/protocol/rest_xml.js:53:29)
    at Request.callListeners (/app/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/app/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/app/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (/app/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/app/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /app/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/app/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/app/node_modules/aws-sdk/lib/request.js:690:12)
    at Request.callListeners (/app/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
4

0 回答 0