Skip to main content

Streaming parser for multipart/form-data

Project description

Streaming multipart/form-data parser

image

image

image

image

streaming_form_data provides a Python parser for parsing multipart/form-data input chunks (the encoding used when submitting data over HTTP through HTML forms).

Installation

$ pip install streaming-form-data

In case you prefer cloning the Github repository and installing manually, please note that develop is the development branch, so stable is what you should be working with.

Usage

>>> from streaming_form_data import StreamingFormDataParser
>>> from streaming_form_data.targets import ValueTarget, FileTarget, NullTarget
>>>
>>> headers = {'Content-Type': 'multipart/form-data; boundary=boundary'}
>>>
>>> parser = StreamingFormDataParser(headers=headers)
>>>
>>> parser.register('name', ValueTarget())
>>> parser.register('file', FileTarget('/tmp/file.txt'))
>>> parser.register('discard-me', NullTarget())
>>>
>>> for chunk in request.body:
...     parser.data_received(chunk)
...
>>>

Documentation

Up-to-date documentation is available on Read the Docs.

Development

Please make sure you have Python 3.6+ and pip-tools installed.

Since this package includes a C extension, please make sure you have a working C compiler available. On Debian-based distros this usually means installing the build-essentials package.

  1. Git clone the repository - git clone https://github.com/siddhantgoel/streaming-form-data

  2. Install the packages required for development - pip install -r requirements-dev.txt

  3. That's basically it. You should now be able to run the test suite - make test.

Please note that tests/test_parser_stress.py stress tests the parser with large inputs, which can take a while. As an alternative, pass the filename as an argument to py.test to run tests selectively.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for streaming-form-data, version 1.10.1
Filename, size File type Python version Upload date Hashes
Filename, size streaming_form_data-1.10.1-cp36-cp36m-macosx_10_9_x86_64.whl (68.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp36-cp36m-manylinux1_i686.whl (300.9 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp36-cp36m-manylinux1_x86_64.whl (314.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp36-cp36m-manylinux2010_i686.whl (300.9 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp36-cp36m-manylinux2010_x86_64.whl (314.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp36-cp36m-win32.whl (54.0 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp36-cp36m-win_amd64.whl (62.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-macosx_10_9_x86_64.whl (65.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-manylinux1_i686.whl (298.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-manylinux1_x86_64.whl (311.8 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-manylinux2010_i686.whl (298.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-manylinux2010_x86_64.whl (311.8 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-win32.whl (54.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp37-cp37m-win_amd64.whl (62.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-macosx_10_9_x86_64.whl (66.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-manylinux1_i686.whl (363.7 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-manylinux1_x86_64.whl (379.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-manylinux2010_i686.whl (363.7 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-manylinux2010_x86_64.whl (379.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-win32.whl (55.2 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming_form_data-1.10.1-cp38-cp38-win_amd64.whl (64.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size streaming-form-data-1.10.1.tar.gz (91.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page