aws-lambda#S3Event TypeScript Examples

The following examples show how to use aws-lambda#S3Event. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: receipt.ts    From heimdall with MIT License 6 votes vote down vote up
handler = async (event: S3Event) => {
  const record = event.Records[0];
  console.log(`Received incoming email (key=${record.s3.object.key})`);

  const s3 = new S3();
  const request = {
    Bucket: record.s3.bucket.name,
    Key: record.s3.object.key
  };

  try {
    const data = await getRecordData(request, s3);
    const email = await simpleParser(data);
    const aliases = extractEmailAliases(email);
    await processAliases(aliases, email);

    await deleteRecord(request, s3);
  } catch (err) {
    await notifyUserOfError(err);
  }
}
Example #2
Source File: markFileReceived.ts    From MDDL with MIT License 6 votes vote down vote up
handler = wrapAsyncHandler(
  async (event: S3Event): Promise<FilesReceivedResponse> => {
    const files: File[] = []
    for (const record of event.Records) {
      const filePath = record.s3.object.key
      const file = await markFileReceived(filePath)
      if (file) {
        files.push(file)
      }
    }
    return { files }
  },
)