Store file after restart dev #1782
Answered
by
thetutlage
quangthienit1994
asked this question in
Help
-
Upload module working very perfect, but I don't know how to stop Adonis auto delete all file uploaded to public folder after restart dev environment. :( |
Beta Was this translation helpful? Give feedback.
Answered by
thetutlage
Oct 22, 2020
Replies: 1 comment 3 replies
-
The uploaded file shouldn't be stored inside the await file.move(Application.tmpPath('uploads')) and then serve them as follows: Route.get('uploads/:filename', ({ response, params }) => {
return response.download(Application.tmpPath('uploads', params.filename))
}) The great thing about custom route is that it gives you the freedom to have custom logic when serving files to the user |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
quangthienit1994
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The uploaded file shouldn't be stored inside the
public
folder. You must store inside a directory outside of thebuild
folder and then create a route to serve the files. Roughly the code should look as follows:and then serve them as follows:
The great thing about custom route is that it gives you the freedom to have custom logic when serving files to the user