grip-framework / grip

The microframework for writing powerful web applications.

Home Page:https://grip-framework.github.io/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: File upload/download

cyangle opened this issue · comments

Is your feature request related to a problem? Please describe.
Helper methods to handle file upload/download requests
Helper methods or documentation to handle streaming video/audio

Currently there's no documentation for how to upload/download files

Describe the solution you'd like
Have something similar to Kemal's send_file helper method in Controller class and documentation of example usages.

Describe alternatives you've considered

Additional context
It needs to handle uploading/downloading files and possibly even streaming for a video/audio website.

You do have fetch_file_params which gives you the file from multipart and you could create a handler to handle uploaded file paths and turn them downloadable.

OK, then I think it's missing file donwload helper similar to kemal's send_file.

There's serve_file method in the static file handler but it's private and you can not access it from the Controller or the Context.

You could add it to the context component:

def send_file(path)
end

def get(context : Context) : Context
  context.send_file("/path/to/your_file")
end

It would be nice if you could create a PR

I'll work on it when I have time.