()
| 194 | } |
| 195 | |
| 196 | async function pull() { |
| 197 | const env = requireR2S3Credentials('pull'); |
| 198 | const client = createR2S3Client(env); |
| 199 | const out = await client.send(new GetObjectCommand({ Bucket: env.bucket, Key: env.key })); |
| 200 | if (!out.Body) { |
| 201 | console.error('R2 GetObject returned an empty body.'); |
| 202 | process.exit(1); |
| 203 | } |
| 204 | const buf = Buffer.from(await out.Body.transformToByteArray()); |
| 205 | writeFileSync(ENCRYPTED_PATH, buf); |
| 206 | console.error(`Wrote ${ENCRYPTED_PATH}`); |
| 207 | } |
| 208 | |
| 209 | const cmd = process.argv[2]; |
| 210 | if (cmd === 'encrypt') { |
no test coverage detected