Gin serve []byte as file

Solution 1:

Use Context.Data to write a []byte as the response.

You can also use Context.DataFromReader to copy directly from the FTP response to the HTTP response.

HTTP responses are a stream of bytes. There's no way to get around that.

Solution 2:

You can write to the ResponseWriter as you are reading the file. It works just like using http.ResponseWriter.

import "io"

//...

io.Copy(ctx.ResponseWriter, ftpReader)