-
Notifications
You must be signed in to change notification settings - Fork 356
Image upload ! #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Image upload ! #271
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| // Require authentication if enabled | ||
| try { | ||
| if (USE_AUTH) { | ||
| await authCheck(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't use server actions in api route context. As an example of how to use auth within an API route, see how its done in copilot response api:
https://github.com/rowboatlabs/rowboat/blob/main/apps/rowboat/app/api/copilot-stream-response/%5BstreamId%5D/route.ts#L11
| const baseKey = `uploaded_images/${dirA}/${dirB}/${id}`; | ||
|
|
||
| // Try known extensions in order | ||
| const exts = ['.png', '.jpg', '.webp', '.bin']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get rid of this logic and have the image extension be a part of id?
| // Accepts an image file (multipart/form-data, field name: "file") | ||
| // Stores it either in S3 (if configured) under uploaded_images/<a>/<b>/<uuid>.<ext> | ||
| // or in the in-memory temp cache. Returns a JSON with a URL that the agent can fetch. | ||
| export async function POST(request: NextRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming we get a presigned upload url from s3, why do we need this route to exist at all? Wouldn't the frontend directly upload to the presigned url?
| @@ -0,0 +1,57 @@ | |||
| import { NextRequest, NextResponse } from 'next/server'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not exist as an API route, but instead as a server action
103a404 to
476654a
Compare
No description provided.