Skip to content
Discussion options

You must be logged in to vote

The uploaded file shouldn't be stored inside the public folder. You must store inside a directory outside of the build folder and then create a route to serve the files. Roughly the code should look as follows:

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

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@quangthienit1994
Comment options

@thetutlage
Comment options

@sasha172017
Comment options

Answer selected by quangthienit1994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants