django-vue3-admin-web/node_modules/@aws-sdk/middleware-location-constraint/dist-cjs/index.js
2025-10-20 21:21:14 +08:00

34 lines
1.2 KiB
JavaScript

'use strict';
function locationConstraintMiddleware(options) {
return (next) => async (args) => {
const { CreateBucketConfiguration } = args.input;
const region = await options.region();
if (!CreateBucketConfiguration?.LocationConstraint && !CreateBucketConfiguration?.Location) {
args = {
...args,
input: {
...args.input,
CreateBucketConfiguration: region === "us-east-1" ? undefined : { LocationConstraint: region },
},
};
}
return next(args);
};
}
const locationConstraintMiddlewareOptions = {
step: "initialize",
tags: ["LOCATION_CONSTRAINT", "CREATE_BUCKET_CONFIGURATION"],
name: "locationConstraintMiddleware",
override: true,
};
const getLocationConstraintPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.add(locationConstraintMiddleware(config), locationConstraintMiddlewareOptions);
},
});
exports.getLocationConstraintPlugin = getLocationConstraintPlugin;
exports.locationConstraintMiddleware = locationConstraintMiddleware;
exports.locationConstraintMiddlewareOptions = locationConstraintMiddlewareOptions;