diff --git a/scripts/upload.ts b/scripts/upload.ts index 33ebf07..af92604 100644 --- a/scripts/upload.ts +++ b/scripts/upload.ts @@ -10,9 +10,29 @@ if (!filePath || !bucketDstName) { process.exit(1); } +const timeSeriesR2Name = bucketDstName + .split("/") + .map((p, i, arr) => { + if (arr.length - 1 !== i) return p; + const fileNameArr = p.split("."); + const fileName = fileNameArr.shift(); + + if (!fileName) return p; + + const newName = `${fileName}-${Date.now()}.${fileNameArr.filter((n) => Boolean(n.match(/./))).join(".")}`; + + return newName; + }) + .join("/"); + await s3UploadFile({ fileName: bucketDstName, filePath, }); +await s3UploadFile({ + fileName: timeSeriesR2Name, + filePath, +}); + console.log(`✅ Uploaded ${filePath}`);