@dotcom-tool-kit/upload-assets-to-s3
Advanced tools
Comparing version 1.0.0-beta.29 to 1.0.0-beta.30
@@ -22,3 +22,3 @@ "use strict"; | ||
bucketByEnv: { | ||
review: 'ft-next-hashed-assets-reivew', | ||
review: 'ft-next-hashed-assets-preview', | ||
prod: ['ft-next-hashed-assets-prod', 'ft-next-hashed-assets-prod-us'] | ||
@@ -50,16 +50,17 @@ }, | ||
const key = path_1.default.posix.join(options.destination, basename); | ||
const params = { | ||
Bucket: '', | ||
Key: key, | ||
Body: fs.createReadStream(file), | ||
ACL: 'public-read', | ||
ContentType: `${type}; charset=utf-8`, | ||
ContentEncoding: encoding, | ||
CacheControl: options.cacheControl | ||
}; | ||
const { review, prod } = options.bucketByEnv; | ||
const bucketByEnv = process.env.NODE_ENV === 'branch' ? review : prod; | ||
let currentBucket = ''; | ||
try { | ||
if (typeof bucketByEnv === 'string') { | ||
params.Bucket = bucketByEnv; | ||
const params = { | ||
Bucket: bucketByEnv, | ||
Key: key, | ||
Body: fs.createReadStream(file), | ||
ACL: 'public-read', | ||
ContentType: `${type}; charset=utf-8`, | ||
ContentEncoding: encoding, | ||
CacheControl: options.cacheControl | ||
}; | ||
currentBucket = params.Bucket; | ||
const data = await s3.upload(params).promise(); | ||
@@ -70,3 +71,12 @@ console.log(`Uploaded ${basename} to ${data.Location}`); | ||
for (const bucket of bucketByEnv) { | ||
params.Bucket = bucket; | ||
const params = { | ||
Bucket: bucket, | ||
Key: key, | ||
Body: fs.createReadStream(file), | ||
ACL: 'public-read', | ||
ContentType: `${type}; charset=utf-8`, | ||
ContentEncoding: encoding, | ||
CacheControl: options.cacheControl | ||
}; | ||
currentBucket = params.Bucket; | ||
const data = await s3.upload(params).promise(); | ||
@@ -78,3 +88,3 @@ console.log(`Uploaded ${basename} to ${data.Location}`); | ||
catch (error) { | ||
console.error(`Upload of ${basename} to ${params.Bucket} failed`); | ||
console.error(`Upload of ${basename} to ${currentBucket} failed`); | ||
throw error; | ||
@@ -81,0 +91,0 @@ } |
{ | ||
"name": "@dotcom-tool-kit/upload-assets-to-s3", | ||
"version": "1.0.0-beta.29", | ||
"version": "1.0.0-beta.30", | ||
"description": "", | ||
@@ -13,3 +13,3 @@ "main": "lib", | ||
"dependencies": { | ||
"@dotcom-tool-kit/task": "^1.0.0-beta.29", | ||
"@dotcom-tool-kit/task": "^1.0.0-beta.30", | ||
"aws-sdk": "^2.901.0", | ||
@@ -16,0 +16,0 @@ "glob": "^7.1.6", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7290
125