diff --git a/src/app/api/upload/route.ts b/src/app/api/upload/route.ts index 05f9427..95428ff 100644 --- a/src/app/api/upload/route.ts +++ b/src/app/api/upload/route.ts @@ -1,4 +1,4 @@ -import { S3Client, PutObjectCommand, ListObjectsV2Command, ListBucketsCommand } from "@aws-sdk/client-s3"; +import { S3Client, PutObjectCommand, ListObjectsV2Command } from "@aws-sdk/client-s3"; import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; import { NextRequest, NextResponse } from "next/server"; @@ -18,31 +18,15 @@ const client = new S3Client({ }, }); -const clientNoBucket = new S3Client({ - region: "auto", - endpoint: `https://${R2.accountId}.r2.cloudflarestorage.com`, - credentials: { - accessKeyId: R2.accessKeyId, - secretAccessKey: R2.secretKey, - }, -}); - const baseUrl = `https://pub-37a76fd657c94d1dbc521a109c087a11.r2.dev/tia`; export async function GET() { try { - // First try listing buckets - const bucketsCmd = new ListBucketsCommand({}); - const bucketsRes = await clientNoBucket.send(bucketsCmd); - console.log("Buckets:", bucketsRes.Buckets); - - // Then list objects in "tia" bucket - const command = new ListObjectsV2Command({ Bucket: "tia" }); + const command = new ListObjectsV2Command({ Bucket: R2.bucket }); const response = await client.send(command); return NextResponse.json({ success: true, - buckets: bucketsRes.Buckets, count: response.Contents?.length || 0, items: response.Contents?.map((o) => ({ key: o.Key,