简体   繁体   English

如何将上传的输入文件存储在 vue nuxt 应用程序的 static 文件夹中?

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

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.通常我们会将图像发送到后端服务进行存储,但这次我想将它们保存到 nuxt static 文件夹中。 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?但是有什么方法可以将上传的文件保存到 static 文件夹或前端的任何位置,使用 vue 和 nuxt?

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. Nuxt 中的static/文件夹仅在构建时使用。 Any resources inside it get mapped to the root / of the domain.它内部的任何资源都映射到域的根/

You cannot insert files into the static/ folder of an uploaded site.您不能将文件插入到已上传站点的static/文件夹中。

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.否则,您必须为添加到本地static/文件夹的每条用户内容重新生成 static 站点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM