# Parse multipart/form-data requests in Falcon
## Install
pip install falcon-multipart
## Usage
Add the `MultipartMiddleware` to your api middlewares:
from falcon_multipart.middleware import MultipartMiddleware
api = falcon.API(middleware=[MultipartMiddleware()])
This will parse any `multipart/form-data` incoming request, and put the keys
in `req._params`, including files, so you get the field as other params.
## Dealing with files
Files will be available as [`cgi.FieldStorage`](https://docs.python.org/3/library/cgi.html),
with following main parameters:
- `file`: act as a python file, you can call `read()` on it, and you will
retrieve content (as *bytes*)
- `filename`: the filename, if given
- `value`: the file content in *bytes*
- `type`: the content-type, or None if not specified
- `disposition`: content-disposition, or None if not specified
## Example
# Say you have a form with those fields:
# - title => a string
# - image => an image file
def on_post(req, resp, **kwargs):
title = req.get_param('title')
image = req.get_param('image')
# Read image as binary
raw = image.file.read()
# Retrieve filename
filename = image.filename
Metadata
Release files for falcon-multipart 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| falcon-multipart-0.2.0.tar.gz | 3.3 kB | Without provenance | Details for falcon-multipart-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| falcon_multipart-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for falcon_multipart-0.2.0-py3-none-any.whl |
Total release size: 8.5 kB
Release files / falcon-multipart-0.2.0.tar.gz
| Download URL | falcon-multipart-0.2.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ae73fdddd94299f2cb181b8f1e8ab17d3ce182daabbb11ce862f0bd471a3d1d
|
|
BLAKE2b-256 checksum How to use checksums |
e0a8cc15f2ff95395859ffc9fedbbcc7731097716a4e4301c0476e24ac5f43c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / falcon_multipart-0.2.0-py3-none-any.whl
| Download URL | falcon_multipart-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
134c88c2b50b343d93e1b0f2c73e0ce07a89928658af71abc9629f42331a189d
|
|
BLAKE2b-256 checksum How to use checksums |
e1a2e50ffc3101ed6b91d1edc63b3586c424ef8071e1ef0ef7dcb8745e65fc14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for falcon-multipart 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.