Fetch Public S3 Object Metadata
Problem Description
Your task is to write a Node.js program using the AWS SDK for JavaScript v3. This program must access a publicly available S3 bucket named coderbytechallengesandbox located in the us-east-1 region. Crucially, the program must operate without requiring any explicit AWS access keys or credentials.
Once connected, your program should perform the following steps:
- List All Objects: Retrieve a list of all objects present in the specified S3 bucket.
- Identify Matching Objects: From the full list, identify all object keys that adhere to the challenge's
cbnaming convention. An example of such a key is__cb__example.txt. - Extract Custom Metadata: For each identified matching object, retrieve its custom metadata.
- Output Format: Return an array of JavaScript objects. Each object in this array should contain two properties:
key(the object's full key) andmetadata(an object containing its custom metadata).
Example Output:
[
{ key: "__cb__example.txt", metadata: { "custom-key": "custom-value" } }
]
Starter Code:
const { S3Client } = require("@aws-sdk/client-s3");
const s3Client = new S3Client({ region: "us-east-1" });
// TODO: implement this
AI interview prep
Core dilemma
Efficiently accessing and processing a potentially large number of S3 objects while adhering to public access constraints and specific data extraction requirements, balancing API call costs and performance.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Fetch Public S3 Object Metadata
Problem Description
Your task is to write a Node.js program using the AWS SDK for JavaScript v3. This program must access a publicly available S3 bucket named coderbytechallengesandbox located in the us-east-1 region. Crucially, the program must operate without requiring any explicit AWS access keys or credentials.
Once connected, your program should perform the following steps:
- List All Objects: Retrieve a list of all objects present in the specified S3 bucket.
- Identify Matching Objects: From the full list, identify all object keys that adhere to the challenge's
cbnaming convention. An example of such a key is__cb__example.txt. - Extract Custom Metadata: For each identified matching object, retrieve its custom metadata.
- Output Format: Return an array of JavaScript objects. Each object in this array should contain two properties:
key(the object's full key) andmetadata(an object containing its custom metadata).
Example Output:
[
{ key: "__cb__example.txt", metadata: { "custom-key": "custom-value" } }
]
Starter Code:
const { S3Client } = require("@aws-sdk/client-s3");
const s3Client = new S3Client({ region: "us-east-1" });
// TODO: implement this