MCPcopy Create free account
hub / github.com/api3dao/airnode / storeFileToBucket

Function storeFileToBucket

packages/airnode-deployer/src/infrastructure/aws.ts:170–184  ·  view source on GitHub ↗
(bucket: Bucket, bucketFilePath: string, filePath: string)

Source from the content-addressed store, hash-verified

168};
169
170export const storeFileToBucket = async (bucket: Bucket, bucketFilePath: string, filePath: string) => {
171 const { name: bucketName, region: bucketRegion } = bucket;
172 const s3 = initializeS3Service(bucketRegion);
173
174 logger.debug(`Storing file '${filePath}' as '${bucketFilePath}' to S3 bucket '${bucketName}'`);
175 const putCommand = new PutObjectCommand({
176 Bucket: bucketName,
177 Key: bucketFilePath,
178 Body: fs.readFileSync(filePath, { encoding: 'utf-8' }),
179 });
180 const goPut = await go(() => s3.send(putCommand));
181 if (!goPut.success) {
182 throw new Error(`Failed to store file '${filePath}' to S3 bucket '${bucketName}': ${goPut.error}`);
183 }
184};
185
186export const getFileFromBucket = async (bucket: Bucket, filePath: string) => {
187 const { name: bucketName, region: bucketRegion } = bucket;

Callers 1

aws.test.tsFile · 0.90

Calls 1

initializeS3ServiceFunction · 0.85

Tested by

no test coverage detected