Debug: add logging to list
This commit is contained in:
parent
9f77e6cfaf
commit
c13b77e5e8
1 changed files with 11 additions and 3 deletions
|
|
@ -34,9 +34,17 @@ export async function GET(req: NextRequest) {
|
|||
const childId = searchParams.get("childId") || "default";
|
||||
const prefix = `memories/${childId}`;
|
||||
|
||||
const command = new ListObjectsV2Command({ Bucket: bucket, Prefix: prefix });
|
||||
const command = new ListObjectsV2Command({ Bucket: bucket, Prefix: prefix, MaxKeys: 10 });
|
||||
const res = await client.send(command);
|
||||
const objects = (res.Contents || []).map((obj) => ({
|
||||
|
||||
// Debug: log what we found
|
||||
console.log("List result:", JSON.stringify(res));
|
||||
|
||||
if (!res.Contents || res.Contents.length === 0) {
|
||||
return NextResponse.json({ memories: [], debug: { bucket, prefix, count: 0 } });
|
||||
}
|
||||
|
||||
const objects = res.Contents.map((obj) => ({
|
||||
key: obj.Key,
|
||||
url: `${baseUrl}/${obj.Key}`,
|
||||
size: obj.Size,
|
||||
|
|
@ -46,7 +54,7 @@ export async function GET(req: NextRequest) {
|
|||
return NextResponse.json({ memories: objects });
|
||||
} catch (error) {
|
||||
console.error("R2 list error:", error);
|
||||
return NextResponse.json({ error: String(error) }, { status: 500 });
|
||||
return NextResponse.json({ error: String(error), stack: error?.stack }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue