lib/services/s3.js
function updateReqBucketRegion(request, region) {
    var httpRequest = request.httpRequest;
    if (typeof region === 'string' && region.length) {
      httpRequest.region = region;
    }
    if (!httpRequest.endpoint.host.match(/s3(?!-accelerate).*\.amazonaws\.com$/)) {
      return;
    }
    var service = request.service;
    var s3Config = service.config;
    var s3BucketEndpoint = s3Config.s3BucketEndpoint;
    if (s3BucketEndpoint) {
      delete s3Config.s3BucketEndpoint;
    }
    var newConfig = AWS.util.copy(s3Config);
    delete newConfig.endpoint;
    newConfig.region = httpRequest.region;

    httpRequest.endpoint = (new AWS.S3(newConfig)).endpoint;
    service.populateURI(request);
    s3Config.s3BucketEndpoint = s3BucketEndpoint;
    httpRequest.headers.Host = httpRequest.endpoint.host;

    if (request._asm.currentState === 'validate') {
      request.removeListener('build', service.populateURI);
      request.addListener('build', service.removeVirtualHostedBucketFromPath);
    }
  }
function updateReqBucketRegion(request, region) {
    var httpRequest = request.httpRequest;
    if (typeof region === 'string' && region.length) {
      httpRequest.region = region;
    }
    if (!httpRequest.endpoint.host.match(/s3(?!-accelerate).*\.amazonaws\.com$/)) {
      return;
    }
    var service = request.service;
    var s3Config = service.config;
    var s3BucketEndpoint = s3Config.s3BucketEndpoint;
    if (s3BucketEndpoint) {
      delete s3Config.s3BucketEndpoint;
    }
    var newConfig = AWS.util.copy(s3Config);
    delete newConfig.endpoint;
    newConfig.region = httpRequest.region;

    httpRequest.endpoint = (new AWS.S3(newConfig)).endpoint;
    service.populateURI(request);
    s3Config.s3BucketEndpoint = s3BucketEndpoint;
    httpRequest.headers.Host = httpRequest.endpoint.host;

    if (request._asm.currentState === 'validate') {
      request.removeListener('build', service.populateURI);
      request.addListener('build', service.removeVirtualHostedBucketFromPath);
    }
  }
function updateReqBucketRegion ( request , region ) { var httpRequest = request . httpRequest ; if ( typeof region === 'string' && region . length ) { httpRequest . region = region ; } if ( ! httpRequest . endpoint . host . match ( / s3(?!-accelerate).*\.amazonaws\.com$ / ) ) { return ; } var service = request . service ; var s3Config = service . config ; var s3BucketEndpoint = s3Config . s3BucketEndpoint ; if ( s3BucketEndpoint ) { delete s3Config . s3BucketEndpoint ; } var newConfig = AWS . util . copy ( s3Config ) ; delete newConfig . endpoint ; newConfig . region = httpRequest . region ; httpRequest . endpoint = ( new AWS . S3 ( newConfig ) ) . endpoint ; service . populateURI ( request ) ; s3Config . s3BucketEndpoint = s3BucketEndpoint ; httpRequest . headers . Host = httpRequest . endpoint . host ; if ( request . _asm . currentState === 'validate' ) { request . removeListener ( 'build' , service . populateURI ) ; request . addListener ( 'build' , service . removeVirtualHostedBucketFromPath ) ; } }
Updates httpRequest with region. If region is not provided, then
the httpRequest will be updated based on httpRequest.region

@api private
Updates httpRequest with region . If region is not provided then the httpRequest will be updated based on httpRequest . region