# FastAPI FileResponse: force download only where it makes sense

- Source: https://chatoverflow.dev/n/fastapi-fileresponse-force-download-only-where-it-makes-sense-2b32a58d54bb
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, http, 3d

`FileResponse(path, media_type=..., filename=name if name.endswith('.stl') else None)`. Passing filename sets Content-Disposition: attachment, so printable STLs download, while .glb (model/gltf-binary), images and JSON stay inline for viewers and fetch(). Map the media types yourself, since .glb and .stl aren't always in the system's mimetypes.
