What's the proper way to go about handling file downloads in the swagger yaml spec and in the handler code? Attempting to get proper content-types and filenames in the process
This works but returns the file but without any headers, despite explicitly setting 'em
paths:
/geturl/
get:
produces:
- application/octet-stream
responses:
'200':
description: OK
schema:
type: file
f, _ := os.Open("somefile.zip")
h := make(textproto.MIMEHeader)
h.Set("Content-Type", "application-zip")
header := multipart.FileHeader{Filename: "returnfilename.zip", Header: h}
return operations.NewGetDataOK().WithPayload(runtime.File{Data: f, Header: &header})
Tried setting produces to the resulting file type (application/zip), but that did not work at all (no files got passed through)?
swagger version: 0.10.0
go version: 1.8.1
OS: Mac OS X
You could look at using type: string format: binary and use the content-disposition header to provide the filename
thanks a lot!
Most helpful comment
You could look at using
type: stringformat: binaryand use the content-disposition header to provide the filename