MCPcopy Create free account
hub / github.com/admineral/OpenAI-Assistant-API-Chat / DELETE

Function DELETE

app/api/deleteFile/route.ts:10–32  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

8});
9
10export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected