GithubHelp home page GithubHelp logo

bbeattie-phxlabs / streaming-form-data Goto Github PK

View Code? Open in Web Editor NEW

This project forked from siddhantgoel/streaming-form-data

0.0 0.0 0.0 12.04 MB

Streaming parser for multipart/form-data written in Python

Home Page: https://streaming-form-data.readthedocs.io/en/latest/

License: MIT License

Python 77.21% Makefile 1.34% Cython 21.45%

streaming-form-data's Introduction

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).

Testimonials

"this speeds up file uploads to my Flask app by more than factor 10"

"Thanks a lot for your fix with streaming-form-data. I can finally upload gigabyte sized files at good speed and without memory filling up!"

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())
>>>
>>> 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: make pip-sync

  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.

streaming-form-data's People

Contributors

siddhantgoel avatar kolomenkin avatar nterysin avatar pyup-bot avatar wouterkoorn avatar raethlein avatar remram44 avatar mephi42 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.