From bc939bc12943c6e8301f4378064bad5f1a5d6bf2 Mon Sep 17 00:00:00 2001 From: tony-cj Date: Fri, 28 Sep 2018 18:08:56 +0800 Subject: [PATCH] support aws cn-north-1 region --- index.js | 6 ++++++ lib/copy.js | 2 ++ lib/delete.js | 2 ++ lib/get.js | 2 ++ lib/keys.js | 1 + 5 files changed, 13 insertions(+) diff --git a/index.js b/index.js index 7ae2570..20d010f 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ var Delete = require('./lib/delete'); * @param {object} [options] - options to provide to the readable stream * @param {object} [options.agent] - an HTTPS agent to use for S3 requests * @param {object} [options.s3] - an S3 client to use to make requests + * @param {object} [options.region] - specify S3 region * @returns {object} a readable stream of line-delimited keys * @example * require('s3scan').List('s3://my-bucket/my-key') @@ -28,6 +29,7 @@ module.exports.List = List; * @param {object} [options] - options to provide to the transform stream * @param {object} [options.agent] - an HTTPS agent to use for S3 requests * @param {object} [options.s3] - an S3 client to use to make requests + * @param {object} [options.region] - specify S3 region * @param {boolean} [options.passErrors] - if `true`, any error objects encountered * will be passed into the readable stream * @param {boolean} [options.keys] - if `true`, `.RequestParameters` (bucket and key) @@ -54,6 +56,7 @@ module.exports.Get = Get; * @param {object} [options] - options to provide to the writable stream * @param {object} [options.agent] - an HTTPS agent to use for S3 requests * @param {object} [options.s3] - an S3 client to use to make requests + * @param {object} [options.region] - specify S3 region * @param {number} [options.concurrency] - concurrency at which to delete objects * @returns {object} a writable stream * @example @@ -71,6 +74,7 @@ module.exports.Delete = Delete; * @param {object} [options] - configuration options * @param {object} [options.agent] - an HTTPS agent to use for S3 requests * @param {object} [options.s3] - an S3 client to use to make requests + * @param {object} [options.region] - specify S3 region * @param {number} [options.concurrency] - concurrency at which to request objects * @param {boolean} [options.passErrors] - if `true`, any error objects encountered * will be passed into the readable stream @@ -105,6 +109,7 @@ module.exports.Scan = function(s3url, options) { * @param {object} [options] - configuration options * @param {object} [options.agent] - an HTTPS agent to use for S3 requests * @param {object} [options.s3] - an S3 client to use to make requests + * @param {object} [options.region] - specify S3 region * @param {number} [options.concurrency] - concurrency at which to delete objects * @param {function} [callback] - a function to run on error or on completion of deletes * @returns {object} a writable stream @@ -151,6 +156,7 @@ module.exports.Purge = function(s3url, options, callback) { * @param {object} [options] - options to provide to the writable stream. * @param {object} [options.agent] - an HTTPS agent to use for S3 requests * @param {object} [options.s3] - an S3 client to use to make requests + * @param {object} [options.region] - specify S3 region * @param {number} [options.concurrency] - concurrency at which to copy objects * @returns {object} a writable stream */ diff --git a/lib/copy.js b/lib/copy.js index 26f09b7..230324f 100644 --- a/lib/copy.js +++ b/lib/copy.js @@ -16,6 +16,8 @@ module.exports = function(fromBucket, toBucket, keyTransform, options) { }; if (options.logger) s3config.logger = options.logger; if (options.agent) s3config.httpOptions.agent = options.agent; + if (options.region) s3config.region = options.region; + var s3 = options.s3 || new AWS.S3(s3config); function write(key, enc, callback) { diff --git a/lib/delete.js b/lib/delete.js index d4e9214..9bea556 100644 --- a/lib/delete.js +++ b/lib/delete.js @@ -11,6 +11,8 @@ module.exports = function(bucket, options) { }; if (options.logger) s3config.logger = options.logger; if (options.agent) s3config.httpOptions.agent = options.agent; + if (options.region) s3config.region = options.region; + var s3 = options.s3 || new AWS.S3(s3config); function write(key, enc, callback) { diff --git a/lib/get.js b/lib/get.js index 4809883..1b16f0d 100644 --- a/lib/get.js +++ b/lib/get.js @@ -18,6 +18,8 @@ module.exports = function(bucket, options) { }; if (options.logger) s3config.logger = options.logger; if (options.agent) s3config.httpOptions.agent = options.agent; + if (options.region) s3config.region = options.region; + var s3 = options.s3 || new AWS.S3(s3config); function transform(key, enc, callback) { diff --git a/lib/keys.js b/lib/keys.js index ec3ebe9..67764e1 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -13,6 +13,7 @@ module.exports = function(s3url, options) { }; if (options.logger) s3config.logger = options.logger; if (options.agent) s3config.httpOptions.agent = options.agent; + if (options.region) s3config.region = options.region; var s3 = options.s3 || new AWS.S3(s3config); s3url = s3urls.fromUrl(s3url);