( client: S3Client, localPath: string, uri: string, contentType?: string, )
| 83 | * adapter handles. |
| 84 | */ |
| 85 | export async function uploadFileToS3( |
| 86 | client: S3Client, |
| 87 | localPath: string, |
| 88 | uri: string, |
| 89 | contentType?: string, |
| 90 | ): Promise<void> { |
| 91 | if (!existsSync(localPath)) { |
| 92 | throw new Error(`[s3Transport] upload source missing: ${localPath}`); |
| 93 | } |
| 94 | const { bucket, key } = parseS3Uri(uri); |
| 95 | const size = statSync(localPath).size; |
| 96 | await client.send( |
| 97 | new PutObjectCommand({ |
| 98 | Bucket: bucket, |
| 99 | Key: key, |
| 100 | Body: createReadStream(localPath), |
| 101 | ContentType: contentType, |
| 102 | ContentLength: size, |
| 103 | }), |
| 104 | ); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Pack a directory into a `.tar.gz` at `destTarball`. Uses the `tar` npm |
no test coverage detected