(req: NextRequest)
| 8 | }); |
| 9 | |
| 10 | export async function DELETE(req: NextRequest) { |
| 11 | const { fileId } = await req.json(); |
| 12 | |
| 13 | // Check if a file ID was provided in the request |
| 14 | if (!fileId) { |
| 15 | console.log('No file ID found in the request'); |
| 16 | return NextResponse.json({ success: false }, { status: 400 }); |
| 17 | } |
| 18 | |
| 19 | try { |
| 20 | // Deleting the file from OpenAI |
| 21 | console.log(`Starting file deletion from OpenAI, File ID: ${fileId}`); |
| 22 | const deletionStatus = await openai.files.del(fileId); |
| 23 | console.log(`File deleted, ID: ${deletionStatus.id}, Status: ${deletionStatus.deleted}`); |
| 24 | |
| 25 | // Respond with the deletion status |
| 26 | return NextResponse.json({ success: deletionStatus.deleted, fileId: deletionStatus.id }); |
| 27 | } catch (error) { |
| 28 | // Log and respond to any errors during the deletion process |
| 29 | console.error('Error deleting file:', error); |
| 30 | return NextResponse.json({ success: false, message: 'Error deleting file' }, { status: 500 }); |
| 31 | } |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected