fix(19.3-03): name stored uploads after their sniffed content through attach.DiskExtension
- DiskExtension: a fixed table of specific sniffed types keeps a matching client extension or uses the canonical one; generic sniffs keep the client extension unless it is script-capable (then txt or bin); never asks package mime - Store names the blob with DiskExtension(sniffed, ext); file_name, the allow-list and the stored content_type are unchanged - TestStoreDiskExtensionSmoke: a PNG uploaded as x.html is stored and served as .png, report.docx keeps .docx, an HTML body named note.txt keeps .txt - attachments docs on disk names, storage deploy note on nosniff and allow-lists, lagoon README
This commit is contained in:
@@ -103,6 +103,8 @@ The route looks up the bucket and the database on each request: `route:list` lis
|
||||
|
||||
Without the key, the application decides where files are served: mount `attach.StaticHandlerPublic` itself, or put a web server or CDN in front of the bucket directory. Either way, serve uploads from a separate origin when you can; the [Attachments](../database/attachments.md) page explains why. The built-in route is meant for development and for deployments that cannot split the origin yet.
|
||||
|
||||
> **Deploy note.** When a static server such as nginx, or a CDN, serves the uploads directory or bucket directly, it picks the Content-Type from the file extension and sends none of the route's headers. `attach.Store` names each file after its sniffed content (`attach.DiskExtension`), so a PNG uploaded as `x.html` is stored as `.png`, but configure the server as the route behaves anyway: send `X-Content-Type-Options: nosniff` on every upload, and serve only the extensions the application accepts (for example the image and document types in `attach.DefaultFileExtensions`), answering 404 for anything else.
|
||||
|
||||
## Upload size
|
||||
|
||||
Every non-raw route has a request body limit of `http.body_limits.default_bytes`. A route that accepts uploads raises its own limit with the `body.limit:<bytes>` middleware; see [Routing](routing.md). `http.body_limits.upload_bytes` is required and validated at start-up, but the framework applies it to no route; a plugin that wants its upload routes to follow it reads it in `Register` and puts the value in the route's `body.limit`.
|
||||
|
||||
Reference in New Issue
Block a user