forked from run-llama/chat-llamaindex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfb409d
commit 0447cfa
Showing
11 changed files
with
734 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { put } from "@vercel/blob"; | ||
import { NextResponse } from "next/server"; | ||
import { URLDetail } from "../../client/fetch/url"; | ||
|
||
export async function POST(request: Request): Promise<NextResponse> { | ||
const { searchParams } = new URL(request.url); | ||
const filename = searchParams.get("filename"); | ||
if (!filename || !request.body) { | ||
return NextResponse.json( | ||
{ error: "Missing filename URL parameter or request body" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
try { | ||
const blob = await put(filename, request.body, { | ||
access: "public", | ||
}); | ||
|
||
const json = { | ||
type: blob.contentType as URLDetail["type"], | ||
url: blob.url, | ||
// TODO: needs to return the size of the uploaded file | ||
size: NaN, | ||
}; | ||
|
||
return NextResponse.json<URLDetail>(json); | ||
} catch (error) { | ||
console.error("[Upload]", error); | ||
return NextResponse.json( | ||
{ | ||
error: (error as Error).message, | ||
}, | ||
{ | ||
status: 500, | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.