Skip to content
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

Additional optional parameter body passed to key function #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rahul1368
Copy link

Earlier we can't access the request.body, inside the key function, because if we use:
await request.json() , this causes error because this is already used inside handler.
So I have passed third optional parameter body to key function, because in order to make the S3 file key more dynamic , we can pass params in request body from the frontend.

await uploadToS3(file, { endpoint: { request: { url: "/api/v1/s3-upload", body: { bucket: "personal", }, }, }, });

So now , we will be able to access bucket value inside the key function from it's third parameter.

`async key(req: NextRequest, filename: string, body?: any){
    let fileKey = `${body.bucket}/${filename}`;
    ........
}`

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-s3-upload ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 10:35pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant