Streaming Python parser for multipart/form-data
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
examples
streaming_form_data
tests
utils
.gitignore
.travis.yml
AUTHORS.rst
CHANGELOG.rst
LICENSE.txt
MANIFEST.in
Makefile
Pipfile
Pipfile.lock
README.rst
setup.py
tox.ini

README.rst

Streaming multipart/form-data parser

https://travis-ci.org/siddhantgoel/streaming-form-data.svg?branch=stable https://readthedocs.org/projects/streaming-form-data/badge/?version=latest

streaming_form_data provides a Python parser for parsing multipart/form-data input chunks (the most commonly used encoding 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 master 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())
>>>
>>> parser.data_received(chunk)

Documentation

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

Development

Please make sure you have Python 3 and pipenv installed.

  1. Git clone the repository - git clone https://github.com/siddhantgoel/streaming-form-data
  2. Install the packages required for development - pipenv install --dev
  3. That's basically it. You should now be able to run the test suite - py.test.