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

Provide a clear example on how to upload files #103

Open
RiadhAdrani opened this issue Feb 9, 2024 · 0 comments
Open

Provide a clear example on how to upload files #103

RiadhAdrani opened this issue Feb 9, 2024 · 0 comments

Comments

@RiadhAdrani
Copy link

RiadhAdrani commented Feb 9, 2024

I am using hono (v3.12.6) in some personal projects lately, it is simple and fun, but when it comes to file handling, I am having some trouble and was not able to figure it out.
I followed the instructions here but with no results :

// ... handlers
.post('/:id/file', async (ctx: AppAuthContext) => {
    const user = ctx.get('user');
    const projectId = ctx.req.param('id');

    const parsed = await ctx.req.parseBody();
    const file = parsed['file'] as File;

    const form = await ctx.req.formData();
    const body = {
      type: form.get('type') as ProjectType,
    };

    const json = await createProjectFile(user, projectId, file, body);

    return ctx.json(json);
  });

and this is my postman request :
image

image

Maybe this is not the correct place for this issue, but I think that a clear example can prevent a lot of headaches.

Thank you.

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

No branches or pull requests

1 participant