(bucket: Bucket, fromFilePath: string, toFilePath: string)
| 206 | }; |
| 207 | |
| 208 | export const copyFileInBucket = async (bucket: Bucket, fromFilePath: string, toFilePath: string) => { |
| 209 | const { name: bucketName, region: bucketRegion } = bucket; |
| 210 | const s3 = initializeS3Service(bucketRegion); |
| 211 | |
| 212 | logger.debug(`Copying file '${fromFilePath}' to file '${toFilePath}' within S3 bucket '${bucketName}'`); |
| 213 | const copyCommand = new CopyObjectCommand({ |
| 214 | Bucket: bucketName, |
| 215 | CopySource: `/${bucketName}/${fromFilePath}`, |
| 216 | Key: toFilePath, |
| 217 | }); |
| 218 | const goCopy = await go(() => s3.send(copyCommand)); |
| 219 | if (!goCopy.success) { |
| 220 | throw new Error( |
| 221 | `Failed to copy file '${fromFilePath}' to file '${toFilePath}' within S3 bucket '${bucketName}': ${goCopy.error}` |
| 222 | ); |
| 223 | } |
| 224 | }; |
| 225 | |
| 226 | const gatherBucketKeys = (directory: Directory): string[] => [ |
| 227 | directory.bucketKey, |
no test coverage detected