Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

falcon-multipart

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

falcon-multipart

Multipart form parsing for Falcon.

  • 0.2.0
  • PyPI
  • Socket score

Maintainers
1

Build Status

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, 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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc