BlobResponse
BlobResponse — descargas de archivos binarios (Content-Disposition inline/attachment, Range requests).
BlobResponse::__construct()
public function __construct(string $file, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true):Parameters
| Name | Type | Description |
|---|---|---|
| $file | string | |
| $status | int | |
| $headers | array<string, string> | |
| $public | bool | |
| $contentDisposition | ?string | |
| $autoEtag | bool | |
| $autoLastModified | bool |
BlobResponse::removeHeaders()
public function removeHeaders(array $headers): voidQuita cabeceras de la respuesta Y del buffer de salida de PHP. Las dos, porque una descarga viaja por `header()` global además del objeto: limpiar sólo el objeto deja al servidor anunciando lo que ya no manda.
Parameters
| Name | Type | Description |
|---|---|---|
| $headers | array<string> |
BlobResponse::download()
public static function download(string $filePath, ?string $fileName = null): selfUn archivo que el navegador guarda, con el nombre que se le indique o el suyo propio.
Parameters
| Name | Type | Description |
|---|---|---|
| $filePath | string | |
| $fileName | ?string |
BlobResponse::inline()
public static function inline(string $filePath, ?string $mimeType = null): selfUn archivo que el navegador MUESTRA en vez de guardar — un PDF, una imagen. Sin el tipo declarado el navegador no sabe si puede mostrarlo y termina descargándolo, que es justo lo que este factory viene a evitar.
Parameters
| Name | Type | Description |
|---|---|---|
| $filePath | string | |
| $mimeType | ?string |
BlobResponse::fromContent()
public static function fromContent(string $content, string $fileName, string $mimeType = 'application/octet-stream'): Milpa\Http\Symfony\HttpResponseUna descarga armada desde contenido en memoria, sin archivo en disco.
Parameters
| Name | Type | Description |
|---|---|---|
| $content | string | |
| $fileName | string | |
| $mimeType | string |