diff --git a/app/api/upload/route.ts b/app/api/upload/route.ts index 8ada232..ea9aab0 100644 --- a/app/api/upload/route.ts +++ b/app/api/upload/route.ts @@ -24,7 +24,6 @@ export async function POST(request: NextRequest) { const buffer = await file.arrayBuffer(); imageBuffer = Buffer.from(buffer); - // 压缩图片 const image = sharp(imageBuffer); const metadata = await image.metadata(); @@ -56,7 +55,6 @@ export async function POST(request: NextRequest) { .toBuffer() as any; } - // 上传到 my_oss const formData2 = new FormData(); const uint8Array = new Uint8Array(imageBuffer); const blob = new Blob([uint8Array], { type: 'image/jpeg' }); @@ -78,8 +76,7 @@ export async function POST(request: NextRequest) { const fileData = await uploadRes.json(); - // 返回 my_oss 的访问URL - const url = `${OSS_URL}/api/files/${fileData.fileKey}/preview`; + const url = `${OSS_URL}/api/files/${fileData.fileKey}/preview?key=${API_KEY}`; return NextResponse.json({ url, fileKey: fileData.fileKey }); } catch (error) { console.error('Upload error:', error);