diff --git a/setup.js b/setup.js index a5ae3e1..b1c0305 100755 --- a/setup.js +++ b/setup.js @@ -16,7 +16,7 @@ const config = { s3enabled: false, s3endpoint: 'sfo3.digitaloceanspaces.com', s3bucket: 'bucket-name', - s3bucketEndpoint: false, + s3usePathStyle: false, s3accessKey: 'accessKey', s3secretKey: 'secretKey', }; @@ -144,10 +144,10 @@ if (require.main === module) { default: config.s3bucket, required: false }, - s3bucketEndpoint: { - description: 'Whether the provided endpoint is a bucket path (true) or a bucket subdomain (false)', + s3usePathStyle: { + description: 'S3 path endpoint, otherwise uses subdomain endpoint', type: 'boolean', - default: config.s3bucketEndpoint, + default: config.s3usePathStyle, required: false }, s3accessKey: { diff --git a/storage.js b/storage.js index 7828439..776608e 100644 --- a/storage.js +++ b/storage.js @@ -8,14 +8,14 @@ const Thumbnail = require('./thumbnails'); const Vibrant = require('./vibrant'); const Hash = require('./hash'); const { getDatedDirname, sanitize, generateId, formatBytes, log } = require('./utils'); -const { s3enabled, s3endpoint, s3bucket, s3bucketEndpoint, s3accessKey, s3secretKey, saveAsOriginal, maxUploadSize, mediaStrict } = require('./config.json'); +const { s3enabled, s3endpoint, s3bucket, s3usePathStyle, s3accessKey, s3secretKey, saveAsOriginal, maxUploadSize, mediaStrict } = require('./config.json'); const { CODE_UNSUPPORTED_MEDIA_TYPE } = require('./MagicNumbers.json'); const ID_GEN_LENGTH = 32; const ALLOWED_MIMETYPES = /(image)|(video)|(audio)\//; const s3 = new aws.S3({ - s3BucketEndpoint: s3bucketEndpoint, + s3ForcePathStyle: s3usePathStyle, endpoint: new aws.Endpoint(s3endpoint), credentials: new aws.Credentials({ accessKeyId: s3accessKey, secretAccessKey: s3secretKey }) });