#How do I handle inputs of type "file" with Astro actions ?

3 messages · Page 1 of 1 (latest)

wheat ibex
#

I want to create an action that looks like this:

    submitProject: defineAction({
        accept: "form",
        input: z.object({
            presentationPicture: z.instanceof(File).optional(),
            name: z.string(),
            summary: z.string(),
            teamMembers: z.number(),
            nature: z.string(),
            date: z.string(),
            description: z.string().optional(),
            showcase: z.boolean(),
            skills: z.string().optional(),
            github: z.string().optional(),
            link: z.string().optional(),
            existingPreviews: z.string().optional(),
        }),
        handler: async (obj, context) => {
            console.log("handling project's submission");
            console.log(obj);
            console.dir(context, { depth: null });
            return {
                success: true,
            };
        },
    }),

but my form has an unknown number of inputs of type "file". How do I handle those files in the handler function ?

lone zodiacBOT
#

Hi @wheat ibex. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain specific information on handling inputs of type "file" with Astro actions. I recommend checking the Astro documentation (https://docs.astro.build/) for more detailed information on this topic.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: