✨ (pagetop): Añade subida y descarga de archivos
- `web::Upload` guarda los archivos de un envío multipart en disco por trozos, con nombre aleatorio, extensiones y tamaño máximo por archivo. `receive()` deserializa además los campos de texto con serde_qs. - `web::Download` sirve un archivo subido con rangos y peticiones condicionales, inline sólo para tipos pasivos y con nosniff. - `form::File`, componente para elegir archivos, y soporte en Bootsier. - Límite del cuerpo según el tipo de contenido: `server.max_body_size` baja a 2 MiB y el nuevo `upload.max_request_size` (32 MiB) se aplica sólo a multipart/form-data.
This commit is contained in:
parent
5540c0c6a0
commit
f3228d6b59
21 changed files with 2240 additions and 17 deletions
|
|
@ -166,6 +166,8 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
.with_id("form-text")
|
||||
.with_action("/")
|
||||
.with_method(form::Method::Post)
|
||||
// Necesaria para enviar los archivos de form::File.
|
||||
.with_enctype(form::Enctype::Multipart)
|
||||
// Campos de texto (form::input::Field).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
|
|
@ -251,6 +253,26 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
.with_help_text(Lc::t("help_rating", &LOC)),
|
||||
),
|
||||
)
|
||||
// Selección de archivos (form::File).
|
||||
.with_child(
|
||||
form::Fieldset::new()
|
||||
.with_legend(Lc::t("fieldset_file", &LOC))
|
||||
.with_child(
|
||||
form::File::new()
|
||||
.with_name("photo")
|
||||
.with_label(Lc::t("label_photo", &LOC))
|
||||
.with_accept("image/jpeg,image/png")
|
||||
.with_help_text(Lc::t("help_photo", &LOC)),
|
||||
)
|
||||
.with_child(
|
||||
form::File::new()
|
||||
.with_name("attachments")
|
||||
.with_label(Lc::t("label_attachments", &LOC))
|
||||
.with_accept(".pdf")
|
||||
.with_multiple(true)
|
||||
.with_help_text(Lc::t("help_attachments", &LOC)),
|
||||
),
|
||||
)
|
||||
// Campo oculto (form::Hidden).
|
||||
.with_child(form::Hidden::field("origin", "form-text"))
|
||||
// Botonera de acciones.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue