#Astro action function not uploading my file to Google Cloud Storage
19 messages · Page 1 of 1 (latest)
Does it ever try to upload?
Nothing logs to the terminal even though I have a console.log there
So what happens when try to upload a file? Anything?
I get an okay o nthe network
but the action didn't really run
at least that's what it seems it does
but nothing
Are you SSR the page?
Unless I am missing a configuration for the nodejs adapter. as part of the setup for SSR
// @ts-check
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import tailwindcss from '@tailwindcss/vite';
import node from '@astrojs/node';
// https://astro.build/config
export default defineConfig({
integrations: [react()],
vite: {
plugins: [tailwindcss()]
},
adapter: node({
mode: 'standalone'
})
});
Set your output to server if you wanna do full SSR. Otherwise you can add the export const prerender at the top.
I see that seems to make a difference I am getting some output in my terminal from the console.log
Okay. So it’s not liking that file upload. Well at least it’s progress
It JUST WORKED. I fixed it. Thanks brother.
It wasn't liking the file upload because the name attribute on the input html element was not the same with the keys in the input z.object. I change it now to match. It is now called selectedVideo
Thanks for the assist brother. A huge W to you 🙂👍
Quick question for you though. I don't know how familiar you are with Astro but what is the best method for doing form submissions.
I know you can submit directly to an API Endpoint.
You can use an Astro action like I am doing here
You can also use an addeventlistener and then make fetech request
What is the best practice.
So the way you are doing it here. Allows for a zero JS form submission. It’s all handled on the server. You can also setup an API endpoint for form submissions. Or call the action client side in the JS. It just depends on you
What’s nice about doing it in the actions. You don’t need the Try Catch Block like you use.
How does Astro actions make the try catch block irrelevant
It’s got it built in. I’ll spin up an example and link it