mirror of https://github.com/fafhrd91/actix-web
Clarify where the limit comes from
This commit is contained in:
parent
7f9577ff5b
commit
e842a0ab56
|
@ -105,7 +105,7 @@ struct ParsedField<'t> {
|
||||||
/// You can use the `#[multipart(limit = "<size>")]` attribute to set field level limits. The limit
|
/// You can use the `#[multipart(limit = "<size>")]` attribute to set field level limits. The limit
|
||||||
/// string is parsed using [`bytesize`].
|
/// string is parsed using [`bytesize`].
|
||||||
///
|
///
|
||||||
/// Note: the form is also subject to the global limits configured using `MultipartFormConfig`.
|
/// Note: the form is also subject to the global limits configured using [`MultipartFormConfig`](crate::form::MultipartFormConfig).
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use actix_multipart::form::{tempfile::TempFile, text::Text, MultipartForm};
|
/// use actix_multipart::form::{tempfile::TempFile, text::Text, MultipartForm};
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct Metadata {
|
||||||
|
|
||||||
#[derive(Debug, MultipartForm)]
|
#[derive(Debug, MultipartForm)]
|
||||||
struct UploadForm {
|
struct UploadForm {
|
||||||
|
// Note: the form is also subject to the global limits configured using `MultipartFormConfig`.
|
||||||
#[multipart(limit = "100MB")]
|
#[multipart(limit = "100MB")]
|
||||||
file: TempFile,
|
file: TempFile,
|
||||||
json: MpJson<Metadata>,
|
json: MpJson<Metadata>,
|
||||||
|
@ -60,6 +61,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
App::new()
|
App::new()
|
||||||
.service(post_video)
|
.service(post_video)
|
||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
|
// Also increase the global total limit to 100MiB.
|
||||||
.app_data(MultipartFormConfig::default().total_limit(100 * 1024 * 1024))
|
.app_data(MultipartFormConfig::default().total_limit(100 * 1024 * 1024))
|
||||||
})
|
})
|
||||||
.workers(2)
|
.workers(2)
|
||||||
|
|
|
@ -11,6 +11,7 @@ struct Metadata {
|
||||||
|
|
||||||
#[derive(Debug, MultipartForm)]
|
#[derive(Debug, MultipartForm)]
|
||||||
struct UploadForm {
|
struct UploadForm {
|
||||||
|
// Note: the form is also subject to the global limits configured using `MultipartFormConfig`.
|
||||||
#[multipart(limit = "100MB")]
|
#[multipart(limit = "100MB")]
|
||||||
file: TempFile,
|
file: TempFile,
|
||||||
json: MpJson<Metadata>,
|
json: MpJson<Metadata>,
|
||||||
|
@ -34,6 +35,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
App::new()
|
App::new()
|
||||||
.service(post_video)
|
.service(post_video)
|
||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
|
// Also increase the global total limit to 100MiB.
|
||||||
.app_data(MultipartFormConfig::default().total_limit(100 * 1024 * 1024))
|
.app_data(MultipartFormConfig::default().total_limit(100 * 1024 * 1024))
|
||||||
})
|
})
|
||||||
.workers(2)
|
.workers(2)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use actix_web::{post, App, HttpServer, Responder};
|
//! use actix_web::{post, App, HttpServer, Responder};
|
||||||
//!
|
//!
|
||||||
//! use actix_multipart::form::{json::Json as MpJson, tempfile::TempFile, MultipartForm};
|
//! use actix_multipart::form::{json::Json as MpJson, tempfile::TempFile, MultipartForm, MultipartFormConfig};
|
||||||
//! use serde::Deserialize;
|
//! use serde::Deserialize;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Debug, Deserialize)]
|
//! #[derive(Debug, Deserialize)]
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
//!
|
//!
|
||||||
//! #[derive(Debug, MultipartForm)]
|
//! #[derive(Debug, MultipartForm)]
|
||||||
//! struct UploadForm {
|
//! struct UploadForm {
|
||||||
|
//! // Note: the form is also subject to the global limits configured using `MultipartFormConfig`.
|
||||||
//! #[multipart(limit = "100MB")]
|
//! #[multipart(limit = "100MB")]
|
||||||
//! file: TempFile,
|
//! file: TempFile,
|
||||||
//! json: MpJson<Metadata>,
|
//! json: MpJson<Metadata>,
|
||||||
|
@ -38,10 +39,15 @@
|
||||||
//!
|
//!
|
||||||
//! #[actix_web::main]
|
//! #[actix_web::main]
|
||||||
//! async fn main() -> std::io::Result<()> {
|
//! async fn main() -> std::io::Result<()> {
|
||||||
//! HttpServer::new(move || App::new().service(post_video))
|
//! HttpServer::new(move || {
|
||||||
//! .bind(("127.0.0.1", 8080))?
|
//! App::new()
|
||||||
//! .run()
|
//! .service(post_video)
|
||||||
//! .await
|
//! // Also increase the global total limit to 100MiB.
|
||||||
|
//! .app_data(MultipartFormConfig::default().total_limit(100 * 1024 * 1024))
|
||||||
|
//! })
|
||||||
|
//! .bind(("127.0.0.1", 8080))?
|
||||||
|
//! .run()
|
||||||
|
//! .await
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
Loading…
Reference in New Issue