How to store uploaded input files in static folder in a vue nuxt application?

Viewed 586

I have a file input form that takes images as input. Normally we would send the image to the backend service to store but this time I want to save them into the nuxt static folder. I know its not an good idea to store dynamic files in the frontend. But is there any way I can save the uploaded files into the static folder or anywhere in the frontend with vue and nuxt ?

1 Answers

What you're describing isn't possible. At least not in a user, or developer, friendly way

The static/ folder in Nuxt is only used at build time. Any resources inside it get mapped to the root / of the domain.

You cannot insert files into the static/ folder of an uploaded site.

If you want to serve user uploaded content, after the build has occurred then the file will need to be sent to the backend and stored appropriately depending on your use case.

Otherwise, you will have to re-generate your static site for each piece of user content you add to your local static/ folder.

Related